Registration and actions for approving authorities
This commit is contained in:
		| @@ -1,11 +0,0 @@ | ||||
| using ApplicationLayer.Services.Locations.Requests; | ||||
|  | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests | ||||
| { | ||||
|     /// Handles edit requests of locations from admins | ||||
|     public interface IEditLocationsRequestsHandler | ||||
|     { | ||||
|         /// Handles add country requests | ||||
|         Task AddCountryAsync(AddCountryRequest request, CancellationToken cancellationToken); | ||||
|     } | ||||
| } | ||||
| @@ -1,12 +0,0 @@ | ||||
| using Domains.LocationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.ApplicantRequests | ||||
| { | ||||
|     /// Handles location requests | ||||
|     public interface ILocationRequestsHandler | ||||
|     { | ||||
|         /// Handle get request | ||||
|         /// <returns>List of available countries</returns> | ||||
|         Task<List<Country>> HandleGetRequestAsync(CancellationToken cancellationToken); | ||||
|     } | ||||
| } | ||||
| @@ -1,14 +0,0 @@ | ||||
| using ApplicationLayer.Services.Locations.NeededServices; | ||||
| using Domains.LocationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.ApplicantRequests | ||||
| { | ||||
|     /// <inheritdoc cref="ILocationRequestsHandler"/> | ||||
|     public class LocationRequestsHandler(ICountriesRepository countries) : ILocationRequestsHandler | ||||
|     { | ||||
|         async Task<List<Country>> ILocationRequestsHandler.HandleGetRequestAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             return await countries.GetAllAsync(cancellationToken); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| using ApplicationLayer.GeneralExceptions; | ||||
| 
 | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests.Exceptions | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.Exceptions | ||||
| { | ||||
|     public class CountryAlreadyExists(string countryName) : AlreadyExistsException($"{countryName} already exists."); | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| using ApplicationLayer.GeneralExceptions; | ||||
| 
 | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests.Exceptions | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.Exceptions | ||||
| { | ||||
|     public class MultipleIdenticalCitiesInCountryException() : ApiException("There are multiple cities with one name in the country."); | ||||
| } | ||||
| @@ -0,0 +1,16 @@ | ||||
| using ApplicationLayer.Services.Locations.Requests; | ||||
| using Domains.LocationDomain; | ||||
|  | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers | ||||
| { | ||||
|     /// Handles location requests | ||||
|     public interface ILocationRequestsHandler | ||||
|     { | ||||
|         /// Handle get request | ||||
|         /// <returns>List of available countries</returns> | ||||
|         Task<List<Country>> HandleGetRequestAsync(CancellationToken cancellationToken); | ||||
|  | ||||
|         /// Handles add country requests | ||||
|         Task AddCountryAsync(AddCountryRequest request, CancellationToken cancellationToken); | ||||
|     } | ||||
| } | ||||
| @@ -1,15 +1,20 @@ | ||||
| using ApplicationLayer.GeneralNeededServices; | ||||
| using ApplicationLayer.Services.Locations.NeededServices; | ||||
| using ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests.Exceptions; | ||||
| using ApplicationLayer.Services.Locations.RequestHandlers.Exceptions; | ||||
| using ApplicationLayer.Services.Locations.Requests; | ||||
| using Domains.LocationDomain; | ||||
| 
 | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests | ||||
| namespace ApplicationLayer.Services.Locations.RequestHandlers | ||||
| { | ||||
|     /// <inheritdoc cref="IEditLocationsRequestsHandler"/> | ||||
|     public class EditLocationsRequestsHandler(ICountriesRepository countries, IUnitOfWork unitOfWork) : IEditLocationsRequestsHandler | ||||
|     /// <inheritdoc cref="ILocationRequestsHandler"/> | ||||
|     public class LocationRequestsHandler(ICountriesRepository countries, IUnitOfWork unitOfWork) : ILocationRequestsHandler | ||||
|     { | ||||
|         async Task IEditLocationsRequestsHandler.AddCountryAsync(AddCountryRequest request, CancellationToken cancellationToken) | ||||
|         async Task<List<Country>> ILocationRequestsHandler.HandleGetRequestAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             return await countries.GetAllAsync(cancellationToken); | ||||
|         } | ||||
| 
 | ||||
|         async Task ILocationRequestsHandler.AddCountryAsync(AddCountryRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (await countries.FindByName(request.CountryName, cancellationToken) is not null) | ||||
|             { | ||||
| @@ -21,6 +26,7 @@ namespace ApplicationLayer.Services.Locations.RequestHandlers.AdminRequests | ||||
|                 throw new MultipleIdenticalCitiesInCountryException(); | ||||
|             } | ||||
| 
 | ||||
|             //todo mapper | ||||
|             var country = new Country | ||||
|             { | ||||
|                 Name = request.CountryName, | ||||
		Reference in New Issue
	
	Block a user