Admin controller, Locations controller, requests to add available countries, request to get available countries
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Domains.Users; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Metadata.Builders; | ||||
|  | ||||
| @@ -16,6 +17,7 @@ public class ApplicantConfiguration : IEntityTypeConfiguration<Applicant> | ||||
|  | ||||
|         entity.HasOne(a => a.CityOfBirth).WithMany().OnDelete(DeleteBehavior.Restrict); | ||||
|         entity.HasOne(a => a.CountryOfBirth).WithMany().OnDelete(DeleteBehavior.Restrict); | ||||
|         entity.HasOne<User>().WithOne().HasForeignKey<Applicant>(a => a.UserId); | ||||
|  | ||||
|         entity.Property(p => p.Citizenship) | ||||
|             .IsUnicode(false) | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| using ApplicationLayer.DataAccessingServices.Applicants.NeededServices; | ||||
| using Domains.ApplicantDomain; | ||||
| using Infrastructure.Database.Applicants.Repositories.Exceptions; | ||||
| using Infrastructure.Database.Generic; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
|  | ||||
| @@ -8,9 +9,8 @@ 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 | ||||
| public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter writer) | ||||
|     : GenericRepository<Applicant>(reader, writer), IApplicantsRepository | ||||
| { | ||||
|     protected override IQueryable<Applicant> LoadDomain() | ||||
|     { | ||||
| @@ -19,4 +19,10 @@ public sealed class ApplicantsRepository(IGenericReader reader, IGenericWriter w | ||||
|             .Include(a => a.CityOfBirth) | ||||
|             .Include(a => a.PlaceOfWork); | ||||
|     } | ||||
|  | ||||
|     async Task<Applicant> IApplicantsRepository.FindByUserIdAsync(Guid userId, CancellationToken cancellationToken) | ||||
|     { | ||||
|         var result = await LoadDomain().SingleOrDefaultAsync(a => a.UserId == userId, cancellationToken); | ||||
|         return result ?? throw new ApplicantNotFoundByUserIdException(userId); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -0,0 +1,10 @@ | ||||
| using Domains.ApplicantDomain; | ||||
| using Infrastructure.Database.GeneralExceptions; | ||||
|  | ||||
| namespace Infrastructure.Database.Applicants.Repositories.Exceptions | ||||
| { | ||||
|     public class ApplicantNotFoundByUserIdException(Guid id) : EntityNotFoundException<Applicant>("Applicant not found.") | ||||
|     { | ||||
|         public Guid UserId { get; private set; } = id; | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user