From f721c168fdd70ab6fe7e23d5f171c74425fbd5c5 Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 19 Feb 2024 08:15:26 -0300 Subject: [PATCH] feature reenvio de e-mail --- OpenAdm.Api/Controllers/PedidoController.cs | 17 +++++++++++++++-- .../Interfaces/IPedidoService.cs | 1 + OpenAdm.Application/Services/PedidoService.cs | 5 +++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/OpenAdm.Api/Controllers/PedidoController.cs b/OpenAdm.Api/Controllers/PedidoController.cs index 362bead..5a0c0a3 100644 --- a/OpenAdm.Api/Controllers/PedidoController.cs +++ b/OpenAdm.Api/Controllers/PedidoController.cs @@ -1,10 +1,8 @@ using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Mvc; using OpenAdm.Api.Attributes; using OpenAdm.Application.Dtos.Pedidos; using OpenAdm.Application.Interfaces; -using OpenAdm.Domain.Exceptions; using OpenAdm.Domain.PaginateDto; namespace OpenAdm.Api.Controllers; @@ -94,4 +92,19 @@ public async Task GetPedidos([FromQuery] int statusPedido) return await HandleErrorAsync(ex); } } + + [IsFuncionario] + [HttpGet("reenviar-pedido")] + public async Task ReenviarPedido([FromQuery] Guid pedidoId) + { + try + { + await _pedidoService.ReenviarPedidoViaEmailAsync(pedidoId); + return Ok(); + } + catch (Exception ex) + { + return await HandleErrorAsync(ex); + } + } } diff --git a/OpenAdm.Application/Interfaces/IPedidoService.cs b/OpenAdm.Application/Interfaces/IPedidoService.cs index e30e67b..45cee36 100644 --- a/OpenAdm.Application/Interfaces/IPedidoService.cs +++ b/OpenAdm.Application/Interfaces/IPedidoService.cs @@ -12,4 +12,5 @@ public interface IPedidoService Task DeletePedidoAsync(Guid id); Task> GetPedidosUsuarioAsync(int statusPedido); Task CreatePedidoAsync(PedidoCreateDto pedidoCreateDto); + Task ReenviarPedidoViaEmailAsync(Guid pedidoId); } diff --git a/OpenAdm.Application/Services/PedidoService.cs b/OpenAdm.Application/Services/PedidoService.cs index 820a9c4..75c9744 100644 --- a/OpenAdm.Application/Services/PedidoService.cs +++ b/OpenAdm.Application/Services/PedidoService.cs @@ -69,6 +69,11 @@ public async Task> GetPedidosUsuarioAsync(int statusPedido .ToList(); } + public async Task ReenviarPedidoViaEmailAsync(Guid pedidoId) + { + await _processarPedidoService.ProcessarCreateAsync(pedidoId); + } + public async Task UpdateStatusPedidoAsync(UpdateStatusPedidoDto updateStatusPedidoDto) { var pedido = await _pedidoRepository.GetPedidoByIdAsync(updateStatusPedidoDto.PedidoId)