Changed exceptions, added action for closing applications by applicant
This commit is contained in:
		| @@ -5,5 +5,5 @@ namespace ApplicationLayer.Services.GeneralExceptions; | ||||
| /// Exception to throw when entity not found | ||||
| /// <param name="id">Identifier of entity</param> | ||||
| /// <typeparam name="T">Type of entity</typeparam> | ||||
| public class EntityNotFoundByIdException<T>(Guid id) : EntityNotFoundException<T>($"{typeof(T).Name} with id {id} not found.") | ||||
| public class EntityNotFoundByIdException<T>(Guid id) : EntityNotFoundException($"{typeof(T).Name} with id {id} not found.") | ||||
|     where T : class, IEntity; | ||||
|   | ||||
| @@ -1,9 +1,6 @@ | ||||
| using ApplicationLayer.GeneralExceptions; | ||||
| using Domains; | ||||
|  | ||||
| namespace ApplicationLayer.Services.GeneralExceptions; | ||||
|  | ||||
| /// Exception to throw when entity not found | ||||
| /// <typeparam name="T">Not found entity type</typeparam> | ||||
| public class EntityNotFoundException<T>(string message) : ApiException(message) | ||||
|     where T : class, IEntity; | ||||
| public class EntityNotFoundException(string message) : ApiException(message); | ||||
|   | ||||
| @@ -14,4 +14,7 @@ public interface IVisaApplicationRequestsHandler | ||||
|  | ||||
|     /// Creates application for applicant with specific user identifier | ||||
|     Task HandleCreateRequest(Guid userId, VisaApplicationCreateRequest request, CancellationToken cancellationToken); | ||||
|  | ||||
|     /// Sets application status to closed | ||||
|     Task HandleCloseRequest(Guid userId, Guid applicationId, CancellationToken cancellationToken); | ||||
| } | ||||
|   | ||||
| @@ -114,4 +114,15 @@ public class VisaApplicationRequestsHandler( | ||||
|  | ||||
|         await unitOfWork.SaveAsync(cancellationToken); | ||||
|     } | ||||
|  | ||||
|     async Task IVisaApplicationRequestsHandler.HandleCloseRequest(Guid userId, Guid applicationId, CancellationToken cancellationToken) | ||||
|     { | ||||
|         var applicantId = await applicants.GetApplicantIdByUserId(userId, cancellationToken); | ||||
|         var application = await applications.GetByApplicantAndApplicationIdAsync(applicantId, applicationId, cancellationToken); | ||||
|  | ||||
|         application.Status = ApplicationStatus.Closed; | ||||
|         await applications.UpdateAsync(application, cancellationToken); | ||||
|  | ||||
|         await unitOfWork.SaveAsync(cancellationToken); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -7,4 +7,7 @@ public interface IVisaApplicationsRepository : IGenericRepository<VisaApplicatio | ||||
| { | ||||
|     /// Get applications of one applicant | ||||
|     Task<List<VisaApplication>> GetOfApplicantAsync(Guid applicantId, CancellationToken cancellationToken); | ||||
|  | ||||
|     /// Get specific application of specific user | ||||
|     Task<VisaApplication> GetByApplicantAndApplicationIdAsync(Guid applicantId, Guid applicationId, CancellationToken cancellationToken); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user