Docker + Jenkfins File + v0.1

This commit is contained in:
Marco Santos
2024-11-18 10:42:44 +00:00
parent 964bad93f1
commit 048d3ea82f
32 changed files with 505 additions and 975 deletions

View File

@@ -1,10 +1,18 @@
using System.ComponentModel;
using GeradoresService.DAL;
using System.ComponentModel;
using System.Net.NetworkInformation;
namespace GeradoresService
{
public class NIF
{
private readonly GeradoresContext _geradoresContext;
public NIF(GeradoresContext geradoresContext)
{
_geradoresContext = geradoresContext;
}
public enum NIFType
{
[Description("Pessoa singular (1)")]
@@ -29,16 +37,14 @@ namespace GeradoresService
PessoaColectivaIrregular = 9
}
/*public static GetNIFTypes(){
EnumHelper.GetEnumValuesAndDescriptions(NIFType);
}*/
public static string Generate(string? type)
public string Generate(string? type)
{
return GenerateRandomNIF(type);
var nif = GenerateRandomNIF(type);
//SaveNIF(nif);
return nif;
}
public static string GenerateRandomNIF(string? nifType)
public string GenerateRandomNIF(string? nifType)
{
var firstDigitValidate = new char[] { '1', '2', '3', '5', '6', '8', '9' };
Random rnd = new Random();
@@ -86,7 +92,7 @@ namespace GeradoresService
return randomNIF;
}
public static bool Validate(string nif)
public bool Validate(string nif)
{
// Verificar se o NIF tem 9 dígitos
if (nif.Length != 9)
@@ -117,5 +123,16 @@ namespace GeradoresService
return digitoControlo == digitos[8];
}
public void SaveNIF(string NIF)
{
var ger = new Geradore()
{
Valor = NIF
};
_geradoresContext.Geradores.Add(ger);
_geradoresContext.SaveChanges();
}
}
}