Changed domains, configured links between VisaApplication and Applicant,created generic repository and repositories for domains
This commit is contained in:
		| @@ -0,0 +1,19 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Configuration | ||||
| { | ||||
|     public class AddressConfiguration : IEntityTypeConfiguration<Address> | ||||
|     { | ||||
|         public void Configure(EntityTypeBuilder<Address> entity) | ||||
|         { | ||||
|             entity.Property(p => p.Street) | ||||
|                 .IsUnicode(false) | ||||
|                 .HasMaxLength(100); | ||||
|             entity.Property(p => p.Building) | ||||
|                 .IsUnicode(false) | ||||
|                 .HasMaxLength(10); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,27 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Configuration | ||||
| { | ||||
|     public class ApplicantConfiguration : IEntityTypeConfiguration<Applicant> | ||||
|     { | ||||
|         public void Configure(EntityTypeBuilder<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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,24 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Configuration | ||||
| { | ||||
|     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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,20 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| 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); | ||||
|  | ||||
|             entity.Property(p => p.Issuer) | ||||
|                 .IsUnicode(false) | ||||
|                 .HasMaxLength(200); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,22 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Configuration | ||||
| { | ||||
|     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); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,18 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Infrastructure.Database.Generic; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Repositories | ||||
| { | ||||
|     public class ApplicantsRepository(IGenericReader reader, IGenericWriter writer, IUnitOfWork unitOfWork) | ||||
|         : GenericRepository<Applicant>(writer, unitOfWork), IApplicantsRepository | ||||
|     { | ||||
|         protected override IQueryable<Applicant> LoadDomain() | ||||
|         { | ||||
|             return reader.GetAll<Applicant>() | ||||
|                 .Include(a => a.CountryOfBirth) | ||||
|                 .Include(a => a.CityOfBirth) | ||||
|                 .Include(a => a.PlaceOfWork); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,7 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Infrastructure.Database.Generic; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Repositories | ||||
| { | ||||
|     public interface IApplicantsRepository : IGenericRepository<Applicant> { } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user