Add project files.
This commit is contained in:
		| @@ -0,0 +1,16 @@ | ||||
| using Core.Blueprint.Service.Domain.Dtos; | ||||
| using Core.Blueprint.Service.UseCases.GetSampleImage.Ports; | ||||
| using Core.Blueprint.Service.UseCases.GetUploadImageUrl.Ports; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
|  | ||||
| namespace Core.Blueprint.Service.UseCases.GetUploadImageUrl.Adapter | ||||
| { | ||||
|     public class GetUploadUrlPort : BasePresenter, IGetUploadUrlPort | ||||
|     { | ||||
|         public void Success(SampleImageUrlDto output) | ||||
|         { | ||||
|             ViewModel = new OkObjectResult(output); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,42 @@ | ||||
| using Core.Blueprint.Service.External.Clients.SampleImageClient; | ||||
| using Core.Blueprint.Service.UseCases.GetUploadImageUrl.Input; | ||||
| using Core.Blueprint.Service.UseCases.GetUploadImageUrl.Ports; | ||||
| using FluentValidation; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Blueprint.Service.UseCases.GetUploadImageUrl | ||||
| { | ||||
|     public class GetUploadUrlHandler(IGetUploadUrlPort port, IValidator<GetUploadUrlRequest> validator, ISampleImageClientService clientService) : IComponentHandler<GetUploadUrlRequest> | ||||
|     { | ||||
|         private readonly IGetUploadUrlPort _port = port; | ||||
|         private readonly IValidator<GetUploadUrlRequest> _validator = validator; | ||||
|         private readonly ISampleImageClientService _clientService = clientService; | ||||
|  | ||||
|         public async ValueTask ExecuteAsync(GetUploadUrlRequest command, CancellationToken cancellationToken = default) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 if (!command.IsValid(_validator)) | ||||
|                 { | ||||
|                     _port.ValidationErrors(command.Notifications); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 var result = await _clientService.GetUploadUrl(); | ||||
|  | ||||
|                 if (result == null) | ||||
|                 { | ||||
|                     _port.NoContentSuccess(); | ||||
|                     return; | ||||
|                 } | ||||
|  | ||||
|                 _port.Success(result); | ||||
|             } | ||||
|             catch(Exception ex) | ||||
|             { | ||||
|                 _port.BusinessError(ex.Message); | ||||
|             } | ||||
|  | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,12 @@ | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Blueprint.Service.UseCases.GetUploadImageUrl.Input | ||||
| { | ||||
|     public class GetUploadUrlRequest : Notificator, ICommand | ||||
|     { | ||||
|         public bool Validate() | ||||
|         { | ||||
|             return true; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,10 @@ | ||||
| using Core.Blueprint.Service.Domain.Dtos; | ||||
| using Core.Blueprint.Service.Domain.Entities; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
|  | ||||
| namespace Core.Blueprint.Service.UseCases.GetUploadImageUrl.Ports | ||||
| { | ||||
|     public interface IGetUploadUrlPort : IBasePort, ICommandSuccessPort<SampleImageUrlDto>, INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort | ||||
|     { | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,16 @@ | ||||
| using Core.Blueprint.Service.UseCases.GetSampleImage.Input; | ||||
| using Core.Blueprint.Service.UseCases.GetUploadImageUrl.Input; | ||||
| using FluentValidation; | ||||
| using System.Diagnostics.CodeAnalysis; | ||||
|  | ||||
| namespace Core.Blueprint.Service.UseCases.GetUploadImageUrl.Validator | ||||
| { | ||||
|     [ExcludeFromCodeCoverage] | ||||
|     public class GetUploadUrlValidator : AbstractValidator<GetUploadUrlRequest> | ||||
|     { | ||||
|         public GetUploadUrlValidator() | ||||
|         { | ||||
|              | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 Sergio Matias Urquin
					Sergio Matias Urquin