Added interfaces to read and write data in DB and added DbContext implementing these

This commit is contained in:
2024-08-13 22:02:50 +03:00
parent 3c17580941
commit b424f0561e
16 changed files with 314 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Configuration.Applicant
{
public class ApplicantConfiguration : IEntityTypeConfiguration<Domains.ApplicantDomain.Applicant>
{
public void Configure(EntityTypeBuilder<Domains.ApplicantDomain.Applicant> entity)
{
entity.ToTable("Applicants");
entity.OwnsOne(p => p.Name);
entity.OwnsOne(p => p.FatherName);
entity.OwnsOne(p => p.MotherName);
entity.OwnsOne(p => p.Passport);
entity.Property(p => p.Citizenship)
.IsUnicode(false)
.HasMaxLength(30);
entity.Property(p => p.CitizenshipByBirth)
.IsUnicode(false)
.HasMaxLength(30);
}
}
}

View File

@@ -0,0 +1,24 @@
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Configuration.Applicant
{
public class NameConfiguration : IEntityTypeConfiguration<Name>
{
public void Configure(EntityTypeBuilder<Name> entity)
{
entity.Property(p => p.FirstName)
.IsUnicode(false)
.HasMaxLength(50);
entity.Property(p => p.Surname)
.IsUnicode(false)
.HasMaxLength(50);
entity.Property(p => p.Patronymic)
.IsUnicode(false)
.HasMaxLength(50);
}
}
}

View File

@@ -0,0 +1,20 @@
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Configuration.Applicant
{
public class PassportConfiguration : IEntityTypeConfiguration<Passport>
{
public void Configure(EntityTypeBuilder<Passport> entity)
{
entity.Property(p => p.Number)
.IsUnicode(false)
.HasMaxLength(20);
entity.Property(p => p.Issuer)
.IsUnicode(false)
.HasMaxLength(200);
}
}
}

View File

@@ -0,0 +1,22 @@
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Configuration.Applicant
{
public class PlaceOfWorkConfiguration : IEntityTypeConfiguration<PlaceOfWork>
{
public void Configure(EntityTypeBuilder<PlaceOfWork> entity)
{
entity.OwnsOne(p => p.Address);
entity.Property(p => p.Name)
.IsUnicode(false)
.HasMaxLength(200);
entity.Property(p => p.PhoneNum)
.IsUnicode(false)
.HasMaxLength(20);
}
}
}