Added validation and fixed errors

This commit is contained in:
2024-08-25 19:49:28 +03:00
parent c92855e7ce
commit 00aa3ab6af
43 changed files with 621 additions and 147 deletions

View File

@@ -1,4 +1,5 @@
using Domains.ApplicantDomain;
using Domains;
using Domains.ApplicantDomain;
using Domains.Users;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
@@ -31,5 +32,9 @@ public class ApplicantConfiguration : IEntityTypeConfiguration<Applicant>
entity.Property(a => a.CityOfBirth)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.CityNameLength);
entity.Property(a => a.JobTitle)
.IsUnicode(false)
.HasMaxLength(ConfigurationConstraints.JobTitleLength);
}
}

View File

@@ -1,4 +1,5 @@
using Domains.ApplicantDomain;
using Domains;
using Domains.ApplicantDomain;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

View File

@@ -18,7 +18,8 @@ public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter w
.Include(a => a.PlaceOfWork);
}
async Task<Applicant> IApplicantsRepository.FindByUserIdAsync(Guid userId, CancellationToken cancellationToken)
/// <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();
@@ -29,4 +30,10 @@ public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter w
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;
}
}