Changed models, added Application layer models

This commit is contained in:
2024-08-15 14:54:23 +03:00
parent 1d8405b4ec
commit c1a4acf414
50 changed files with 628 additions and 647 deletions

View File

@@ -2,18 +2,17 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
namespace Infrastructure.Database.Applicants.Configuration;
public class AddressConfiguration : IEntityTypeConfiguration<Address>
{
public class AddressConfiguration : IEntityTypeConfiguration<Address>
public void Configure(EntityTypeBuilder<Address> entity)
{
public void Configure(EntityTypeBuilder<Address> entity)
{
entity.Property(p => p.Street)
.IsUnicode(false)
.HasMaxLength(100);
entity.Property(p => p.Building)
.IsUnicode(false)
.HasMaxLength(10);
}
entity.Property(p => p.Street)
.IsUnicode(false)
.HasMaxLength(100);
entity.Property(p => p.Building)
.IsUnicode(false)
.HasMaxLength(10);
}
}
}

View File

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

View File

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

View File

@@ -2,19 +2,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration
{
public class PassportConfiguration : IEntityTypeConfiguration<Passport>
{
public void Configure(EntityTypeBuilder<Passport> entity)
{
entity.Property(p => p.Number)
.IsUnicode(false)
.HasMaxLength(20);
namespace Infrastructure.Database.Applicants.Configuration;
entity.Property(p => p.Issuer)
.IsUnicode(false)
.HasMaxLength(200);
}
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

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

View File

@@ -2,21 +2,20 @@
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
namespace Infrastructure.Database.Applicants.Repositories
namespace Infrastructure.Database.Applicants.Repositories;
/// Repository pattern for <see cref="Applicant"/>
/// <param name="reader"><inheritdoc cref="IGenericReader"/></param>
/// <param name="writer"><inheritdoc cref="IGenericWriter"/></param>
/// <param name="unitOfWork"><inheritdoc cref="IUnitOfWork"/></param>
public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork)
: GenericRepository<Applicant>(reader, writer, unitOfWork), IApplicantsRepository
{
/// Repository pattern for <see cref="Applicant"/>
/// <param name="reader"><inheritdoc cref="IGenericReader"/></param>
/// <param name="writer"><inheritdoc cref="IGenericWriter"/></param>
/// <param name="unitOfWork"><inheritdoc cref="IUnitOfWork"/></param>
public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork)
: GenericRepository<Applicant>(reader, writer, unitOfWork), IApplicantsRepository
protected override IQueryable<Applicant> LoadDomain()
{
protected override IQueryable<Applicant> LoadDomain()
{
return base.LoadDomain()
.Include(a => a.CountryOfBirth)
.Include(a => a.CityOfBirth)
.Include(a => a.PlaceOfWork);
}
return base.LoadDomain()
.Include(a => a.CountryOfBirth)
.Include(a => a.CityOfBirth)
.Include(a => a.PlaceOfWork);
}
}
}

View File

@@ -1,8 +1,7 @@
using Domains.ApplicantDomain;
using Infrastructure.Database.Generic;
namespace Infrastructure.Database.Applicants.Repositories
{
/// Repository pattern for <see cref="Applicant"/>
public interface IApplicantsRepository : IGenericRepository<Applicant> { }
}
namespace Infrastructure.Database.Applicants.Repositories;
/// Repository pattern for <see cref="Applicant"/>
public interface IApplicantsRepository : IGenericRepository<Applicant> { }