diff --git a/README.md b/README.md index 9074ed0..6975a89 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,7 @@ - EasyNetQ - Application Query Stack e Specification Pattern - NetDevPack +- Facade # Ferramentas - Visual Studio 2022 - Version 17.11.4 ++ diff --git a/src/services/JSE.Pagamento.API/appsettings.Development.json b/src/services/JSE.Pagamento.API/appsettings.Development.json index ec61c56..d96fd35 100644 --- a/src/services/JSE.Pagamento.API/appsettings.Development.json +++ b/src/services/JSE.Pagamento.API/appsettings.Development.json @@ -25,5 +25,4 @@ "DefaultApiKey": "ak_ewr4dsWehiwAT", "DefaultEncryptionKey": "ek_SweRsdFas4uT5" } - } diff --git a/src/services/JSE.Pedido.API/Configuration/MessageBusConfig.cs b/src/services/JSE.Pedido.API/Configuration/MessageBusConfig.cs index 9269e8c..1497f78 100644 --- a/src/services/JSE.Pedido.API/Configuration/MessageBusConfig.cs +++ b/src/services/JSE.Pedido.API/Configuration/MessageBusConfig.cs @@ -1,5 +1,6 @@ using JSE.Core.Utils; using JSE.MessageBus; +using JSE.Pedidos.API.Services; namespace JSE.Pedidos.API.Configuration { @@ -8,7 +9,8 @@ public static class MessageBusConfig public static void AddMessageBusConfiguration(this IServiceCollection services, IConfiguration configuration) { - services.AddMessageBus(configuration.GetMessageQueueConnection("MessageBus")); + services.AddMessageBus(configuration.GetMessageQueueConnection("MessageBus")) + .AddHostedService(); } } } \ No newline at end of file diff --git a/src/services/JSE.Pedido.API/Controllers/PedidoController.cs b/src/services/JSE.Pedido.API/Controllers/PedidoController.cs index e575396..726d757 100644 --- a/src/services/JSE.Pedido.API/Controllers/PedidoController.cs +++ b/src/services/JSE.Pedido.API/Controllers/PedidoController.cs @@ -6,7 +6,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -namespace JSE.Pedido_API.Controllers +namespace JSE.Pedidos.API.Controllers { [Authorize] public class PedidoController : MainController diff --git a/src/services/JSE.Pedido.API/Services/PedidoOrquestradorIntegrationHandler.cs b/src/services/JSE.Pedido.API/Services/PedidoOrquestradorIntegrationHandler.cs new file mode 100644 index 0000000..bc69ac7 --- /dev/null +++ b/src/services/JSE.Pedido.API/Services/PedidoOrquestradorIntegrationHandler.cs @@ -0,0 +1,43 @@ + +namespace JSE.Pedidos.API.Services +{ + public class PedidoOrquestradorIntegrationHandler : IHostedService, IDisposable + { + private readonly ILogger _logger; + private Timer _timer; + + public PedidoOrquestradorIntegrationHandler(ILogger logger) + { + _logger = logger; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("Serviço de pedidos iniciado."); + + _timer = new Timer(ProcessarPedidos, null, TimeSpan.Zero, + TimeSpan.FromSeconds(15)); + + return Task.CompletedTask; + } + + private async void ProcessarPedidos(object state) + { + _logger.LogInformation("Processando Pedidos"); + } + + public Task StopAsync(CancellationToken cancellationToken) + { + _logger.LogInformation("Serviço de pedidos finalizado."); + + _timer?.Change(Timeout.Infinite, 0); + + return Task.CompletedTask; + } + + public void Dispose() + { + _timer?.Dispose(); + } + } +} diff --git a/src/web/JSE.WebApp.MVC/Views/Pedido/ConfirmacaoPedido.cshtml b/src/web/JSE.WebApp.MVC/Views/Pedido/ConfirmacaoPedido.cshtml new file mode 100644 index 0000000..0c44488 --- /dev/null +++ b/src/web/JSE.WebApp.MVC/Views/Pedido/ConfirmacaoPedido.cshtml @@ -0,0 +1,110 @@ +@using JSE.WebApp.MVC.Extensions +@model JSE.WebApp.MVC.Models.PedidoViewModel + +@{ + ViewData["Title"] = "Pedido confirmado!"; +} + +
+
+ + + + @{ + if (Model.PedidoItems.Any()) + { +
+
+
+ + + + Endereço +
+
+ + + + Pagamento +
+
+ + + + Confirmação +
+
+
+
+

Pedido concluído com sucesso!

+
+
+ @{ + foreach (var item in Model.PedidoItems) + { +
+
+
+ @item.Nome +
+
+

+ @item.Nome +

+ @this.UnidadesPorProdutoValorTotal(item.Quantidade, item.Valor) +
+
+
+ } + } + +
+
+ +
+

Pedido número: #@Model.Codigo

+
+
+ +
+
+
+
Entregar em
+

+ @Model.Endereco.ToString() +

+
+
+
Pagamento
+ + + Transação em cartão de crédito + +

+ Total: @this.FormatoMoeda(Model.ValorTotal) +

+
+
+ +
+
+ + + +
+ } + } +
+
+ +@section Scripts { + + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + } + +} \ No newline at end of file diff --git a/src/web/JSE.WebApp.MVC/Views/Pedido/MeusPedidos.cshtml b/src/web/JSE.WebApp.MVC/Views/Pedido/MeusPedidos.cshtml new file mode 100644 index 0000000..eab2bee --- /dev/null +++ b/src/web/JSE.WebApp.MVC/Views/Pedido/MeusPedidos.cshtml @@ -0,0 +1,68 @@ +@using JSE.WebApp.MVC.Extensions +@model IEnumerable + +@{ + ViewData["Title"] = "Meus Pedidos"; +} + +
+
+ + @{ + foreach (var pedido in Model.OrderBy(p=>p.Data)) + { +
+
+
+ Pedido ID: #@pedido.Codigo @Html.Raw(this.ExibeStatus(pedido.Status)) + @pedido.Data.ToLongDateString() +
+
+
+
+
Pagamento
+ + + Transação em cartão de crédito + + +

+ Total: @this.FormatoMoeda(pedido.ValorTotal) +

+ +
+
+
Endereço de entrega
+

+ @pedido.Endereco.ToString() +

+
+
+
+
    + @{ + foreach (var item in pedido.PedidoItems) + { +
  • +
    +
    + @item.Nome +
    +
    +

    + @item.Nome +

    + @this.UnidadesPorProdutoValorTotal(item.Quantidade, item.Valor) +
    +
    +
  • + } + } +
+
+
+
+ } + } +
+
\ No newline at end of file