Вытащил солюшен на уровень выше, чтобы прощё было дотнетить
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2025-10-05 14:32:06 +03:00
parent fa87a56ad1
commit aae4b28089
242 changed files with 159 additions and 159 deletions

View File

@@ -0,0 +1,27 @@
using Domains;
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration;
public static class AddressConfiguration<T> where T : class, IEntity
{
public static void Configure(OwnedNavigationBuilder<T, Address> entity)
{
entity.Property(a => a.Country)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CountryNameLength);
entity.Property(a => a.City)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CityNameLength);
entity.Property(a => a.Street)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.StreetNameLength);
entity.Property(a => a.Building)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.BuildingNumberLength);
}
}

View File

@@ -0,0 +1,40 @@
using Domains;
using Domains.ApplicantDomain;
using Domains.Users;
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.OwnsOne(a => a.Name, NameConfiguration<Applicant>.Configure);
entity.OwnsOne(a => a.FatherName, NameConfiguration<Applicant>.Configure);
entity.OwnsOne(a => a.MotherName, NameConfiguration<Applicant>.Configure);
entity.OwnsOne(a => a.Passport, PassportConfiguration<Applicant>.Configure);
entity.HasOne<User>().WithOne().HasForeignKey<Applicant>(a => a.UserId);
entity.Property(a => a.Citizenship)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CitizenshipLength);
entity.Property(a => a.CitizenshipByBirth)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CitizenshipLength);
entity.Property(a => a.CountryOfBirth)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CountryNameLength);
entity.Property(a => a.CityOfBirth)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CityNameLength);
entity.Property(a => a.JobTitle)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.JobTitleLength);
}
}

View File

@@ -0,0 +1,23 @@
using Domains;
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration;
public static class NameConfiguration<T> where T : class, IEntity
{
public static void Configure(OwnedNavigationBuilder<T, Name> entity)
{
entity.Property(p => p.FirstName)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.NameLength);
entity.Property(p => p.Surname)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.NameLength);
entity.Property(p => p.Patronymic)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.NameLength);
}
}

View File

@@ -0,0 +1,19 @@
using Domains;
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Infrastructure.Database.Applicants.Configuration;
public static class PassportConfiguration<T> where T : class, IEntity
{
public static void Configure(OwnedNavigationBuilder<T, Passport> entity)
{
entity.Property(p => p.Number)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.PassportNumberLength);
entity.Property(p => p.Issuer)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.IssuerNameLength);
}
}

View File

@@ -0,0 +1,22 @@
using Domains;
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, AddressConfiguration<PlaceOfWork>.Configure);
entity.Property(p => p.Name)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.PlaceOfWorkNameLength);
entity.Property(p => p.PhoneNum)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.PhoneNumberLength);
}
}

View File

@@ -0,0 +1,39 @@
using ApplicationLayer.Services.Applicants.NeededServices;
using Domains.ApplicantDomain;
using Infrastructure.Database.Applicants.Repositories.Exceptions;
using Infrastructure.Database.Generic;
using Microsoft.EntityFrameworkCore;
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>
public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter writer)
: GenericRepository<Applicant>(reader, writer), IApplicantsRepository
{
protected override IQueryable<Applicant> LoadDomain()
{
return base.LoadDomain()
.Include(a => a.PlaceOfWork);
}
/// <inheritdoc cref="IApplicantsRepository.FindByUserIdAsync"/>
public async Task<Applicant> FindByUserIdAsync(Guid userId, CancellationToken cancellationToken)
{
var result = await LoadDomain().SingleOrDefaultAsync(a => a.UserId == userId, cancellationToken);
return result ?? throw new ApplicantNotFoundByUserIdException();
}
async Task<Guid> IApplicantsRepository.GetApplicantIdByUserId(Guid userId, CancellationToken cancellationToken)
{
var result = await base.LoadDomain().SingleOrDefaultAsync(a => a.UserId == userId, cancellationToken);
return result?.Id ?? throw new ApplicantNotFoundByUserIdException();
}
async Task<bool> IApplicantsRepository.IsApplicantNonResidentByUserId(Guid userId, CancellationToken cancellationToken)
{
var applicant = await FindByUserIdAsync(userId, cancellationToken);
return applicant.IsNonResident;
}
}

View File

@@ -0,0 +1,5 @@
using ApplicationLayer.GeneralExceptions;
namespace Infrastructure.Database.Applicants.Repositories.Exceptions;
public class ApplicantNotFoundByUserIdException() : EntityNotFoundException("Applicant not found.");