Docker + Jenkfins File + v0.1
This commit is contained in:
13
GeradoresService/DAL/Geradore.cs
Normal file
13
GeradoresService/DAL/Geradore.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace GeradoresService.DAL;
|
||||
|
||||
public partial class Geradore
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public int? Tipo { get; set; }
|
||||
|
||||
public string? Valor { get; set; }
|
||||
}
|
||||
34
GeradoresService/DAL/GeradoresContext.cs
Normal file
34
GeradoresService/DAL/GeradoresContext.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace GeradoresService.DAL;
|
||||
|
||||
public partial class GeradoresContext : DbContext
|
||||
{
|
||||
public GeradoresContext()
|
||||
{
|
||||
}
|
||||
|
||||
public GeradoresContext(DbContextOptions<GeradoresContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<Geradore> Geradores { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Geradore>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__Geradore__3214EC2710D5AD88");
|
||||
|
||||
entity.Property(e => e.Id).HasColumnName("ID");
|
||||
entity.Property(e => e.Valor).HasMaxLength(50);
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
}
|
||||
@@ -1,9 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="DAL\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user