Added validation and fixed errors
This commit is contained in:
		| @@ -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); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -1,4 +1,5 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Domains; | ||||
| using Domains.ApplicantDomain; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
|   | ||||
| @@ -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; | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user