diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..3f9164f
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,155 @@
+root = true
+
+# Regras gerais para C#
+[*.cs]
+#charset = utf-8
+dotnet_diagnostic.SA0001.severity = none
+dotnet_diagnostic.IDE0005.severity = none
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = true
+
+# Forçar severidade padrão dos analisadores Roslyn
+dotnet_analyzer_diagnostic.severity = warning
+
+# Estilo de código recomendados (exemplos)
+dotnet_style_qualification_for_field = false:suggestion
+dotnet_style_qualification_for_property = false:suggestion
+dotnet_style_qualification_for_method = false:suggestion
+dotnet_style_qualification_for_event = false:suggestion
+
+# Ordenação de using
+dotnet_sort_system_directives_first = true:warning
+
+# Exemplos de severidade para regras específicas (StyleCop)
+dotnet_diagnostic.SA1200.severity = none
+dotnet_diagnostic.SA1309.severity = none
+
+# Nomes e formatos (exemplo simples)
+dotnet_naming_rule.private_fields_should_be_camel_case.severity = suggestion
+
+# Regras de nomenclatura
+dotnet_naming_rule.private_fields_should_be_camel_case.severity = suggestion
+dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields
+dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case
+
+dotnet_naming_symbols.private_fields.applicable_kinds = field
+dotnet_naming_symbols.private_fields.applicable_accessibilities = private
+
+dotnet_naming_style.camel_case.capitalization = camel_case
+
+# Regras de estilo de código
+csharp_style_expression_bodied_methods = false:suggestion
+csharp_style_expression_bodied_constructors = false:suggestion
+csharp_style_expression_bodied_operators = false:suggestion
+csharp_style_expression_bodied_properties = true:suggestion
+csharp_style_expression_bodied_indexers = true:suggestion
+csharp_style_expression_bodied_accessors = true:suggestion
+
+csharp_style_var_for_built_in_types = true:suggestion
+csharp_style_var_when_type_is_apparent = true:suggestion
+csharp_style_var_elsewhere = true:suggestion
+
+csharp_style_prefer_method_group_conversion = true:suggestion
+csharp_style_prefer_top_level_statements = true:suggestion
+csharp_style_prefer_primary_constructors = false:suggestion
+
+# Regras de espaço e formatação
+csharp_space_after_cast = false
+csharp_space_after_keywords_in_control_flow_statements = true
+csharp_space_between_method_call_parameter_list_parentheses = false
+csharp_space_between_method_declaration_parameter_list_parentheses = false
+
+# Default severity for analyzer diagnostics with category 'StyleCop.CSharp.DocumentationRules'
+dotnet_analyzer_diagnostic.category-StyleCop.CSharp.DocumentationRules.severity = none
+
+# SYSLIB1045: Converter em 'GeneratedRegexAttribute'.
+dotnet_diagnostic.SYSLIB1045.severity = none
+
+# SA1101: Prefix local calls with this
+dotnet_diagnostic.SA1101.severity = none
+
+# IDE1006: Estilos de Nomenclatura
+dotnet_diagnostic.IDE1006.severity = none
+
+# IDE0058: O valor da expressão nunca é usado
+dotnet_diagnostic.IDE0058.severity = none
+
+# IDE0046: Converter em expressão condicional
+dotnet_diagnostic.IDE0046.severity = suggestion
+
+# SA1201: Elements should appear in the correct order
+dotnet_diagnostic.SA1201.severity = suggestion
+
+# IDE0041: Usar verificação 'is null'
+dotnet_diagnostic.IDE0041.severity = suggestion
+
+# SA1503: Braces should not be omitted
+dotnet_diagnostic.SA1503.severity = suggestion
+
+# IDE0011: Adicionar chaves
+dotnet_diagnostic.IDE0011.severity = none
+
+# IDE0028: Simplificar a inicialização de coleção
+dotnet_diagnostic.IDE0028.severity = suggestion
+
+# IDE0200: Remover expressão lambda desnecessária
+dotnet_diagnostic.IDE0200.severity = suggestion
+
+# IDE0305: Simplificar a inicialização de coleção
+dotnet_diagnostic.IDE0305.severity = suggestion
+
+# IDE0060: Remover o parâmetro não utilizado
+dotnet_diagnostic.IDE0060.severity = suggestion
+
+# CA1720: O identificador contém o nome de tipo
+dotnet_diagnostic.CA1720.severity = none
+
+# Desabilita SA1633 (cabeçalho de arquivo) globalmente para arquivos C#
+dotnet_diagnostic.SA1633.severity = none
+
+# SA1413: Use trailing comma in multi-line initializers
+dotnet_diagnostic.SA1413.severity = suggestion
+
+# IDE0100: Remover a igualdade redundante
+dotnet_diagnostic.IDE0100.severity = none
+
+# CA1816: Os métodos Dispose devem chamar SuppressFinalize
+dotnet_diagnostic.CA1816.severity = suggestion
+
+# IDE0052: Remover membros particulares não lidos
+dotnet_diagnostic.IDE0052.severity = suggestion
+
+# CA1051: Não declarar campos de instância visíveis
+dotnet_diagnostic.CA1051.severity = suggestion
+
+# SA1401: Fields should be private
+dotnet_diagnostic.SA1401.severity = suggestion
+
+# SA1306: Field names should begin with lower-case letter
+dotnet_diagnostic.SA1306.severity = suggestion
+
+# SA1100: Do not prefix calls with base unless local implementation exists
+dotnet_diagnostic.SA1100.severity = suggestion
+
+# CA1707: Identificadores não devem conter sublinhados
+dotnet_diagnostic.CA1707.severity = none
+
+# IDE0022: Usar o corpo do bloco para método
+dotnet_diagnostic.IDE0022.severity = none
+
+# IDE0301: Simplificar a inicialização de coleção
+dotnet_diagnostic.IDE0301.severity = suggestion
+
+# CA1305: Especificar IFormatProvider
+dotnet_diagnostic.CA1305.severity = suggestion
+
+# IDE0059: Atribuição desnecessária de um valor
+dotnet_diagnostic.IDE0059.severity = suggestion
+
+# CS8604: Possível argumento de referência nula.
+dotnet_diagnostic.CS8604.severity = suggestion
+
+# CA1827: Não usar Count() ou LongCount() quando Any() puder ser usado
+dotnet_diagnostic.CA1827.severity = suggestion
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..1e703ba
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,35 @@
+
+
+
+ net8.0
+
+
+ enable
+ enable
+
+
+ 12.0
+
+
+ true
+
+
+ true
+ true
+ latest
+ $(TreatWarningsAsErrors)
+
+
+ https://github.com/rinaldoserra-dev/plataforma-educacao-devops
+
+
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
+
diff --git a/PlataformaEducacao.sln b/PlataformaEducacao.sln
index 8eb8d60..0cf2578 100644
--- a/PlataformaEducacao.sln
+++ b/PlataformaEducacao.sln
@@ -97,6 +97,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Core", "Core", "{81405219-1
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlataformaEducacao.Core.Tests", "src\tests\PlataformaEducacaoCore\PlataformaEducacao.Core.Tests.csproj", "{7CF9F8F1-2CFE-4543-9F1B-D1D819344A03}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlataformaEducacao.GestaoConteudo.Data.Tests", "src\tests\PlataformaEducacao.GestaoConteudo.Data.Tests\PlataformaEducacao.GestaoConteudo.Data.Tests.csproj", "{0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -443,6 +445,18 @@ Global
{7CF9F8F1-2CFE-4543-9F1B-D1D819344A03}.Release|x64.Build.0 = Release|Any CPU
{7CF9F8F1-2CFE-4543-9F1B-D1D819344A03}.Release|x86.ActiveCfg = Release|Any CPU
{7CF9F8F1-2CFE-4543-9F1B-D1D819344A03}.Release|x86.Build.0 = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|x64.Build.0 = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Debug|x86.Build.0 = Debug|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|x64.ActiveCfg = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|x64.Build.0 = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|x86.ActiveCfg = Release|Any CPU
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -494,6 +508,7 @@ Global
{CB93565F-3313-4670-AB4C-8F71ADF66D63} = {56D316E0-2671-4404-9D44-01FCE4AD8192}
{81405219-192E-4FA9-96E4-F550F8A8386F} = {56D316E0-2671-4404-9D44-01FCE4AD8192}
{7CF9F8F1-2CFE-4543-9F1B-D1D819344A03} = {81405219-192E-4FA9-96E4-F550F8A8386F}
+ {0EDB1AC8-CC4B-487F-83AA-3072C0CF5689} = {53FF5E3B-DD37-43A1-9553-3B4135CA7E9E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5076C19C-1C60-4400-A9A6-CA081FE46BAE}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/ApiConfig.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/ApiConfig.cs
index f40429f..9196f1e 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/ApiConfig.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/ApiConfig.cs
@@ -20,6 +20,7 @@ public static IHostBuilder ConfigureAppSettings(this IHostBuilder host)
return host;
}
+
public static IServiceCollection AddApiConfig(this IServiceCollection services, IConfiguration configuration)
{
services.AddControllers();
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/MessageBusConfig.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/MessageBusConfig.cs
index 4df6775..5d071dd 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/MessageBusConfig.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/MessageBusConfig.cs
@@ -1,9 +1,14 @@
-namespace PlataformaEducacao.Bff.Api.Configurations
+using PlataformaEducacao.Core.Utils;
+using PlataformaEducacao.MessageBus;
+
+namespace PlataformaEducacao.Bff.Api.Configurations
{
public static class MessageBusConfig
{
public static IServiceCollection AddMessageBusConfiguration(this IServiceCollection services, IConfiguration configuration)
{
+ services.AddMessageBus(configuration.GetMessageQueueConnection("MessageBus"));
+
return services;
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/SwaggerConfig.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/SwaggerConfig.cs
index c4e266b..0d5b221 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/SwaggerConfig.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Configurations/SwaggerConfig.cs
@@ -16,7 +16,6 @@ public static IServiceCollection AddSwaggerConfiguration(this IServiceCollection
License = new OpenApiLicense { Name = "MIT", Url = new Uri("https://opensource.org/licenses/MIT") }
});
-
option.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
@@ -38,10 +37,9 @@ public static IServiceCollection AddSwaggerConfiguration(this IServiceCollection
Id = "Bearer"
}
},
- new string[] {}
+ Array.Empty()
}
});
-
});
return services;
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/BaseController.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/BaseController.cs
index 45668e1..564ace9 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/BaseController.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/BaseController.cs
@@ -24,7 +24,7 @@ protected ActionResult CustomResponse(ModelStateDictionary modelState)
protected ActionResult CustomResponse(ResponseResult response)
{
- if (response == null || !response.Sucesso || response.Erros.Mensagens.Any())
+ if (response == null || !response.Sucesso || response.Erros.Mensagens.Count != 0)
{
return BadRequest(response);
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoAlunosController.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoAlunosController.cs
index e95a6a7..5a665a2 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoAlunosController.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoAlunosController.cs
@@ -1,10 +1,10 @@
-using Microsoft.AspNetCore.Authorization;
+using System.Text.Json;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PlataformaEducacao.Bff.Api.Models.GestaoAlunos;
using PlataformaEducacao.Bff.Api.Models.GestaoConteudo;
using PlataformaEducacao.Bff.Api.Services;
using PlataformaEducacao.WebApi.Core.Controllers;
-using System.Text.Json;
namespace PlataformaEducacao.Bff.Api.Controllers
{
@@ -30,9 +30,7 @@ public async Task Matricular(MatricularDTO matricular)
}
var cursoDetalhes = JsonSerializer.Deserialize(
- curso!.Data.ToString()!,
- new JsonSerializerOptions { PropertyNameCaseInsensitive = true }
- );
+ curso.Data.ToString(), JsonSerializerOptions);
if (cursoDetalhes != null)
{
@@ -115,5 +113,10 @@ public async Task BaixarCertificado(Guid certificadoId)
return File(bytes, contentType, fileName.Trim('"'));
}
+
+ private static readonly JsonSerializerOptions JsonSerializerOptions = new()
+ {
+ PropertyNameCaseInsensitive = true
+ };
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoConteudoController.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoConteudoController.cs
index d140766..ce9e938 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoConteudoController.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Controllers/GestaoConteudoController.cs
@@ -24,6 +24,7 @@ public async Task AdicionarCurso([FromBody] AdicionarCursoRequest
return CustomResponse(resposta);
}
+
[HttpPut("{id:guid}")]
[Authorize(Roles = "ADMIN")]
public async Task Atualizar(Guid id, [FromBody] AtualizarCursoRequest cursoRequest)
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/AppServicesSettings.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/AppServicesSettings.cs
index ab99f22..f33ceda 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/AppServicesSettings.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/AppServicesSettings.cs
@@ -3,8 +3,11 @@
public class AppServicesSettings
{
public string IdentidadeUrl { get; set; } = string.Empty;
+
public string GestaoConteudoUrl { get; set; } = string.Empty;
+
public string GestaoAlunosUrl { get; set; } = string.Empty;
+
public string GestaoFinanceiraUrl { get; set; } = string.Empty;
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/HttpClientAuthorizationDelegatingHandler.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/HttpClientAuthorizationDelegatingHandler.cs
index 5a5114a..89446a0 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/HttpClientAuthorizationDelegatingHandler.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Extensions/HttpClientAuthorizationDelegatingHandler.cs
@@ -13,20 +13,19 @@ public HttpClientAuthorizationDelegatingHandler(IAspNetUser aspNetUser)
protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
- var authorizationHeader = _aspNetUser.ObterHttpContext().Request.Headers["Authorization"];
+ var authorizationHeader = _aspNetUser.ObterHttpContext().Request.Headers.Authorization;
if (!string.IsNullOrEmpty(authorizationHeader))
{
- request.Headers.Add("Authorization", new List() { authorizationHeader! });
+ request.Headers.Add("Authorization", new List() { authorizationHeader });
}
- //var token = _aspNetUser.ObterUserToken();
+ // var token = _aspNetUser.ObterUserToken();
- //if (!string.IsNullOrEmpty(authorizationHeader))
- //{
+ // if (!string.IsNullOrEmpty(authorizationHeader))
+ // {
// request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI1MTE0OGJlNy05ZDA5LTQwOWUtYTFiNi0xZDI1ODI4YzM2NjkiLCJlbWFpbCI6ImFkbWluQHRlc3RlLmNvbSIsImp0aSI6IjQ5OGUxMWVjLTM0ZjktNDlkOS1iYzY0LWU3NTk3OGIyMGQ3NCIsIm5iZiI6MTc3MDM5MjI4MywiaWF0IjoxNzcwMzkyMjgzLCJyb2xlIjoiQURNSU4iLCJleHAiOjE3NzAzOTk0ODMsImlzcyI6IlBsYXRhZm9ybWFFZHVjYWNhbyIsImF1ZCI6Imh0dHBzOi8vbG9jYWxob3N0In0.N8St5rJDb-iUgsJbc5WhESypBwXMhbAFZ6IUNbsCmRM");
- //}
-
+ // }
return await base.SendAsync(request, cancellationToken);
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoAlunos/RealizarAulaDTO.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoAlunos/RealizarAulaDTO.cs
index 6bedd17..7b356db 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoAlunos/RealizarAulaDTO.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoAlunos/RealizarAulaDTO.cs
@@ -13,4 +13,4 @@ public class RealizarAulaDTO
[Required(ErrorMessage = "O id da aula é obrigatório.")]
public Guid AulaId { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoConteudo/CursoDetalhesDTO.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoConteudo/CursoDetalhesDTO.cs
index 3442129..3ebd98e 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoConteudo/CursoDetalhesDTO.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/GestaoConteudo/CursoDetalhesDTO.cs
@@ -3,9 +3,13 @@ namespace PlataformaEducacao.Bff.Api.Models.GestaoConteudo
public class CursoDetalhesDTO
{
public Guid Id { get; set; }
+
public string Nome { get; set; } = string.Empty;
+
public decimal Valor { get; set; }
+
public bool Disponivel { get; set; }
+
public IEnumerable Aulas { get; set; } = Enumerable.Empty();
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Health/HealthStatusDTO.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Health/HealthStatusDTO.cs
index a448b25..3a708e3 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Health/HealthStatusDTO.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Health/HealthStatusDTO.cs
@@ -3,9 +3,13 @@ namespace PlataformaEducacao.Bff.Api.Models.Health
public class HealthStatusDTO
{
public string Servico { get; set; } = string.Empty;
+
public string Url { get; set; } = string.Empty;
+
public bool Saudavel { get; set; }
+
public int Status { get; set; }
+
public string Mensagem { get; set; } = string.Empty;
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarAulaRequest.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarAulaRequest.cs
index 53fbef6..8f0cfc5 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarAulaRequest.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarAulaRequest.cs
@@ -6,12 +6,18 @@ public class AdicionarAulaRequest
{
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public Guid CursoId { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
+
public string Titulo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
+
public string Conteudo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public int Ordem { get; set; }
+
public string? Material { get; set; }
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarCursoRequest.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarCursoRequest.cs
index ea339c8..ed5b9e7 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarCursoRequest.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AdicionarCursoRequest.cs
@@ -1,5 +1,5 @@
-using PlataformaEducacao.WebApi.Core.Extensions;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
+using PlataformaEducacao.WebApi.Core.Extensions;
namespace PlataformaEducacao.Bff.Api.Models.Request.GestaoConteudo
{
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AtualizarCursoRequest.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AtualizarCursoRequest.cs
index c58923e..ba9bc53 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AtualizarCursoRequest.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/GestaoConteudo/AtualizarCursoRequest.cs
@@ -6,14 +6,19 @@ public class AtualizarCursoRequest
{
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public Guid Id { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string Nome { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string DescricaoConteudo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public int CargaHoraria { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public decimal Valor { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public bool Disponivel { get; set; }
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/Identidade/RefreshTokenRequest.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/Identidade/RefreshTokenRequest.cs
index 130a419..0d56d2e 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/Identidade/RefreshTokenRequest.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Models/Request/Identidade/RefreshTokenRequest.cs
@@ -6,6 +6,5 @@ public class RefreshTokenRequest
{
[Required(ErrorMessage = "O campo {0} é obrigatório")]
public string RefreshToken { get; set; } = string.Empty;
-
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Program.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Program.cs
index f064f43..968b4c0 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Program.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Program.cs
@@ -23,4 +23,6 @@
app.Run();
-public partial class Program { }
+public partial class Program
+{
+}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/AlunosService.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/AlunosService.cs
index 4edc77e..2a220bc 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/AlunosService.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/AlunosService.cs
@@ -9,12 +9,19 @@ namespace PlataformaEducacao.Bff.Api.Services
public interface IAlunosService
{
Task Matricular(MatricularDTO solicitarMatricula);
+
Task ObterMatriculasPendentesPagamento();
+
Task ObterMatriculasAtivas();
+
Task ValidarCertificado(string codigoVerificacao);
+
Task RealizarAula(RealizarAulaDTO realizarAula);
+
Task FinalizarCurso(FinalizarCursoDTO finalizarCurso);
+
Task ObterHistorico(Guid alunoId);
+
Task BaixarCertificado(Guid certificadoId);
}
@@ -23,21 +30,22 @@ public class AlunosService : Service, IAlunosService
private readonly HttpClient _httpClient;
private readonly ICursosService _cursosService;
- public AlunosService(HttpClient httpClient,
- ICursosService cursosService,
- IOptions settings)
+ public AlunosService(
+ HttpClient httpClient,
+ ICursosService cursosService,
+ IOptions settings)
{
_httpClient = httpClient;
_cursosService = cursosService;
_httpClient.BaseAddress = new Uri(settings.Value.GestaoAlunosUrl);
}
- public async Task Matricular(MatricularDTO matricular)
+ public async Task Matricular(MatricularDTO solicitarMatricula)
{
- if (DadosCursoPreenchidos(matricular) is false)
+ if (DadosCursoPreenchidos(solicitarMatricula) is false)
{
- var cursoResponse = await _cursosService.ObterCursoComAulasPorCursoId(matricular.CursoId);
- if (cursoResponse.Sucesso is false || cursoResponse.Erros.Mensagens.Any())
+ var cursoResponse = await _cursosService.ObterCursoComAulasPorCursoId(solicitarMatricula.CursoId);
+ if (cursoResponse.Sucesso is false || cursoResponse.Erros.Mensagens.Count != 0)
{
return cursoResponse;
}
@@ -82,12 +90,12 @@ public async Task Matricular(MatricularDTO matricular)
};
}
- matricular.NomeCurso = curso.Nome;
- matricular.Valor = curso.Valor;
- matricular.TotalAulasCurso = curso.Aulas.Count();
+ solicitarMatricula.NomeCurso = curso.Nome;
+ solicitarMatricula.Valor = curso.Valor;
+ solicitarMatricula.TotalAulasCurso = curso.Aulas.Count();
}
- var conteudoMatricular = ObterConteudo(matricular);
+ var conteudoMatricular = ObterConteudo(solicitarMatricula);
var response = await _httpClient.PostAsync("/api/alunos/matricular", conteudoMatricular);
return await DeserializarObjetoResponse(response);
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/CursosService.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/CursosService.cs
index 3560ac2..e733f5a 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/CursosService.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/CursosService.cs
@@ -8,14 +8,18 @@ namespace PlataformaEducacao.Bff.Api.Services
public interface ICursosService
{
Task AdicionarCurso(AdicionarCursoRequest cursoRequest);
+
Task AtualizarCurso(Guid cursoId, AtualizarCursoRequest cursoRequest);
+
Task AdicionarAula(AdicionarAulaRequest aulaRequest);
+
Task ObterCursosDisponiveisComAula();
- Task ObterCursoComAulasPorCursoId(Guid cursoId);
- Task ObterTodos();
+ Task ObterCursoComAulasPorCursoId(Guid cursoId);
+ Task ObterTodos();
}
+
public class CursosService : Service, ICursosService
{
private readonly HttpClient _httpClient;
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/HealthCheckService.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/HealthCheckService.cs
index 129d9a9..190d387 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/HealthCheckService.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/HealthCheckService.cs
@@ -15,8 +15,9 @@ public class HealthCheckService : Service, IHealthCheckService
private readonly HttpClient _httpClient;
private readonly AppServicesSettings _settings;
- public HealthCheckService(HttpClient httpClient,
- IOptions settings)
+ public HealthCheckService(
+ HttpClient httpClient,
+ IOptions settings)
{
_httpClient = httpClient;
_settings = settings.Value;
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/IdentidadeService.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/IdentidadeService.cs
index 492acf4..dc917e2 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/IdentidadeService.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/IdentidadeService.cs
@@ -8,7 +8,9 @@ namespace PlataformaEducacao.Bff.Api.Services
public interface IIdentidadeService
{
Task RegistrarAluno(RegistroAlunoRequest aluno);
+
Task Login(LoginRequest login);
+
Task RefreshToken(RefreshTokenRequest refreshToken);
}
@@ -38,7 +40,6 @@ public async Task RegistrarAluno(RegistroAlunoRequest aluno)
var response = await _httpClient.PostAsync("/api/identidade/novo-aluno/", alunoContent);
return await DeserializarObjetoResponse(response);
-
}
public async Task RefreshToken(RefreshTokenRequest refreshToken)
@@ -48,7 +49,6 @@ public async Task RefreshToken(RefreshTokenRequest refreshToken)
var response = await _httpClient.PostAsync("/api/identidade/refresh-token/", refreshTokenContent);
return await DeserializarObjetoResponse(response);
-
}
}
}
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/PagamentoService.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/PagamentoService.cs
index a38af31..fd66597 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/PagamentoService.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/PagamentoService.cs
@@ -8,7 +8,9 @@ namespace PlataformaEducacao.Bff.Api.Services
public interface IPagamentoService
{
Task PagarMatricula(PagarMatriculaDTO pagamento);
+
Task ObterStatus(Guid matriculaId);
+
Task HealthCheck();
}
@@ -16,8 +18,9 @@ public class PagamentoService : Service, IPagamentoService
{
private readonly HttpClient _httpClient;
- public PagamentoService(HttpClient httpClient,
- IOptions settings)
+ public PagamentoService(
+ HttpClient httpClient,
+ IOptions settings)
{
_httpClient = httpClient;
_httpClient.BaseAddress = new Uri(settings.Value.GestaoFinanceiraUrl);
diff --git a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/Service.cs b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/Service.cs
index 35b0c22..3af6529 100644
--- a/src/api-gateways/PlataformaEducacao.Bff.Api/Services/Service.cs
+++ b/src/api-gateways/PlataformaEducacao.Bff.Api/Services/Service.cs
@@ -1,6 +1,6 @@
-using PlataformaEducacao.Core.Communication;
-using System.Text;
+using System.Text;
using System.Text.Json;
+using PlataformaEducacao.Core.Communication;
namespace PlataformaEducacao.Bff.Api.Services
{
@@ -15,6 +15,7 @@ protected StringContent ObterConteudo(object dado)
Encoding.UTF8,
"application/json");
}
+
protected async Task DeserializarObjetoResponse(HttpResponseMessage responseMessage)
{
var stringContent = await responseMessage.Content.ReadAsStringAsync();
@@ -30,7 +31,9 @@ protected async Task DeserializarObjetoResponse(HttpResponseMess
return result;
}
}
- catch (JsonException) { }
+ catch (JsonException)
+ {
+ }
}
return new ResponseResult
@@ -59,22 +62,20 @@ protected async Task DeserializarObjetoResponse(HttpResponseMess
return default;
}
- //protected async Task DeserializarObjetoResponse(HttpResponseMessage responseMessage)
- //{
+ // protected async Task DeserializarObjetoResponse(HttpResponseMessage responseMessage)
+ // {
// var options = new JsonSerializerOptions
// {
// PropertyNameCaseInsensitive = true
// };
-
// return JsonSerializer.Deserialize(await responseMessage.Content.ReadAsStringAsync(), options);
- //}
+ // }
- //protected bool TratarErrosResponse(HttpResponseMessage response)
- //{
+ // protected bool TratarErrosResponse(HttpResponseMessage response)
+ // {
// if (response.StatusCode == HttpStatusCode.BadRequest) return false;
-
// response.EnsureSuccessStatusCode();
// return true;
- //}
+ // }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseErrorMessages.cs b/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseErrorMessages.cs
new file mode 100644
index 0000000..9a0bbde
--- /dev/null
+++ b/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseErrorMessages.cs
@@ -0,0 +1,12 @@
+namespace PlataformaEducacao.Core.Communication
+{
+ public class ResponseErrorMessages
+ {
+ public ResponseErrorMessages()
+ {
+ Mensagens = new List();
+ }
+
+ public List Mensagens { get; set; }
+ }
+}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseResult.cs b/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseResult.cs
index 13803a6..0cec937 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseResult.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Communication/ResponseResult.cs
@@ -3,18 +3,11 @@
public class ResponseResult
{
public int Status { get; set; }
+
public bool Sucesso { get; set; }
- public object? Data { get; set; }
- public ResponseErrorMessages Erros { get; set; } = new();
- }
- public class ResponseErrorMessages
- {
- public ResponseErrorMessages()
- {
- Mensagens = new List();
- }
+ public object? Data { get; set; }
- public List Mensagens { get; set; }
+ public ResponseErrorMessages Erros { get; set; } = new();
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Data/IRepository.cs b/src/building-blocks/PlataformaEducacao.Core/Data/IRepository.cs
index 22257b3..5e39986 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Data/IRepository.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Data/IRepository.cs
@@ -2,8 +2,8 @@
namespace PlataformaEducacao.Core.Data
{
-
- public interface IRepository : IDisposable where T : IAggregateRoot
+ public interface IRepository : IDisposable
+ where T : IAggregateRoot
{
IUnitOfWork UnitOfWork { get; }
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/DomainException.cs b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/DomainException.cs
index c7a782f..2e2d514 100644
--- a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/DomainException.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/DomainException.cs
@@ -6,11 +6,13 @@ public DomainException()
{
}
- public DomainException(string message) : base(message)
+ public DomainException(string message)
+ : base(message)
{
}
- public DomainException(string message, Exception innerException) : base(message, innerException)
+ public DomainException(string message, Exception innerException)
+ : base(message, innerException)
{
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Email.cs b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Email.cs
index 505728d..591b270 100644
--- a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Email.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Email.cs
@@ -6,21 +6,28 @@ public class Email
{
public const int EnderecoMaxLength = 254;
public const int EnderecoMinLength = 5;
- public string Endereco { get; private set; } = null!;
-
- //Construtor do EntityFramework
- protected Email() { }
public Email(string endereco)
{
- if (!Validar(endereco)) throw new DomainException("E-mail inválido");
+ if (!Validar(endereco))
+ {
+ throw new DomainException("E-mail inválido");
+ }
+
Endereco = endereco;
}
+ // Construtor do EntityFramework
+ protected Email()
+ {
+ }
+
+ public string Endereco { get; private set; } = null!;
+
public static bool Validar(string email)
{
var regexEmail = new Regex(@"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$");
return regexEmail.IsMatch(email);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Entity.cs b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Entity.cs
index 79cbb20..5279ec7 100644
--- a/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Entity.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/DomainObjects/Entity.cs
@@ -4,27 +4,42 @@ namespace PlataformaEducacao.Core.DomainObjects
{
public abstract class Entity
{
- public Guid Id { get; set; }
+ private List _notificacoes;
protected Entity()
{
Id = Guid.NewGuid();
- _notificacoes = new List();
+ _notificacoes = [];
}
- private List _notificacoes;
- public IReadOnlyCollection Notificacoes => _notificacoes.AsReadOnly();
- public void AdicionarEvento(Event evento)
+ public Guid Id { get; set; }
+
+ public static bool operator ==(
+ Entity? a, Entity? b)
{
- _notificacoes = _notificacoes ?? new List();
+ if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
+ return true;
+
+ if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
+ return false;
+
+ return a.Equals(b);
+ }
+
+ public IReadOnlyCollection Notificacoes => _notificacoes.AsReadOnly();
+
+ public void AdicionarEvento(Evento evento)
+ {
+ _notificacoes ??= [];
_notificacoes.Add(evento);
}
+
public void DefinirId(Guid id)
{
Id = id;
}
- public void RemoverEvento(Event eventItem)
+ public void RemoverEvento(Evento eventItem)
{
_notificacoes?.Remove(eventItem);
}
@@ -38,21 +53,17 @@ public override bool Equals(object? obj)
{
var compareTo = obj as Entity;
- if (ReferenceEquals(this, compareTo)) return true;
- if (ReferenceEquals(null, compareTo)) return false;
-
- return Id.Equals(compareTo.Id);
- }
-
- public static bool operator ==(Entity? a, Entity? b)
- {
- if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
+ if (ReferenceEquals(this, compareTo))
+ {
return true;
+ }
- if (ReferenceEquals(a, null) || ReferenceEquals(b, null))
+ if (compareTo is null)
+ {
return false;
+ }
- return a.Equals(b);
+ return Id.Equals(compareTo.Id);
}
public static bool operator !=(Entity? a, Entity? b)
@@ -69,6 +80,7 @@ public override string ToString()
{
return $"{GetType().Name} [Id={Id}]";
}
+
public virtual bool EhValido()
{
throw new NotImplementedException();
diff --git a/src/building-blocks/PlataformaEducacao.Core/Mediator/IMediatorHandler.cs b/src/building-blocks/PlataformaEducacao.Core/Mediator/IMediatorHandler.cs
index 682a457..fb5048b 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Mediator/IMediatorHandler.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Mediator/IMediatorHandler.cs
@@ -5,7 +5,10 @@ namespace PlataformaEducacao.Core.Mediator
{
public interface IMediatorHandler
{
- Task PublishEvent(T evento) where T : Event;
- Task SendCommand(T comando) where T : Command;
+ Task PublishEvent(T evento)
+ where T : Evento;
+
+ Task SendCommand(T comando)
+ where T : Command;
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Mediator/MediatorHandler.cs b/src/building-blocks/PlataformaEducacao.Core/Mediator/MediatorHandler.cs
index 133db75..230abe5 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Mediator/MediatorHandler.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Mediator/MediatorHandler.cs
@@ -13,12 +13,14 @@ public MediatorHandler(IMediator mediator)
_mediator = mediator;
}
- public async Task SendCommand(T comando) where T : Command
+ public async Task SendCommand(T comando)
+ where T : Command
{
return await _mediator.Send(comando);
}
- public async Task PublishEvent(T evento) where T : Event
+ public async Task PublishEvent(T evento)
+ where T : Evento
{
await _mediator.Publish(evento);
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Command.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Command.cs
index 89376d6..e5935c7 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Command.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Command.cs
@@ -6,6 +6,7 @@ namespace PlataformaEducacao.Core.Messages
public abstract class Command : Message, IRequest
{
public DateTime Timestamp { get; private set; }
+
public ValidationResult ValidationResult { get; set; } = new();
protected Command()
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/CommandHandler.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/CommandHandler.cs
index 57c1bbf..66f1ca1 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/CommandHandler.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/CommandHandler.cs
@@ -5,13 +5,14 @@ namespace PlataformaEducacao.Core.Messages
{
public abstract class CommandHandler
{
- protected ValidationResult ValidationResult;
-
protected CommandHandler()
{
ValidationResult = new ValidationResult();
}
+ // Expor o ValidationResult para classes derivadas
+ protected ValidationResult ValidationResult { get; }
+
protected void AdicionarErro(string mensagem)
{
ValidationResult.Errors.Add(new ValidationFailure(string.Empty, mensagem));
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Event .cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Event .cs
index c6c61e5..b461861 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Event .cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Event .cs
@@ -2,9 +2,9 @@
namespace PlataformaEducacao.Core.Messages
{
- public class Event : Message, INotification
+ public class Evento : Message, INotification
{
- protected Event()
+ protected Evento()
{
Timestamp = DateTime.Now;
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IniciaPagamentoIntegrationEvent.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IniciaPagamentoIntegrationEvent.cs
index f1ba0df..2899e61 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IniciaPagamentoIntegrationEvent.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IniciaPagamentoIntegrationEvent.cs
@@ -16,12 +16,19 @@ public IniciaPagamentoIntegrationEvent(Guid matriculaId, Guid alunoId, decimal v
}
public Guid MatriculaId { get; private set; }
+
public Guid AlunoId { get; private set; }
+
public decimal Valor { get; private set; }
+
public int TipoPagamento { get; set; }
+
public string NomeCartao { get; private set; }
+
public string NumeroCartao { get; private set; }
+
public string ExpiracaoCartao { get; private set; }
+
public string CvvCartao { get; private set; }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IntegrationEvent.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IntegrationEvent.cs
index 167a9dd..90602c0 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IntegrationEvent.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/IntegrationEvent.cs
@@ -1,6 +1,6 @@
namespace PlataformaEducacao.Core.Messages.Integration
{
- public abstract class IntegrationEvent : Event
+ public abstract class IntegrationEvent : Evento
{
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/ResponseMessage.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/ResponseMessage.cs
index 49cd86c..50cf7e4 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/ResponseMessage.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/ResponseMessage.cs
@@ -4,11 +4,11 @@ namespace PlataformaEducacao.Core.Messages.Integration
{
public class ResponseMessage : Message
{
- public ValidationResult ValidationResult { get; set; }
-
public ResponseMessage(ValidationResult validationResult)
{
ValidationResult = validationResult;
}
+
+ public ValidationResult ValidationResult { get; set; }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/UsuarioRegistradoIntegrationEvent.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/UsuarioRegistradoIntegrationEvent.cs
index 4a7d318..0c0f62c 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/UsuarioRegistradoIntegrationEvent.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Integration/UsuarioRegistradoIntegrationEvent.cs
@@ -11,7 +11,9 @@ public UsuarioRegistradoIntegrationEvent(Guid usuarioId, string nome, string ema
}
public Guid UsuarioId { get; private set; }
+
public string Nome { get; private set; } = string.Empty;
+
public string Email { get; private set; } = string.Empty;
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Messages/Message.cs b/src/building-blocks/PlataformaEducacao.Core/Messages/Message.cs
index 328c47c..8180775 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Messages/Message.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Messages/Message.cs
@@ -8,6 +8,7 @@ protected Message()
}
public string MessageType { get; protected set; }
+
public Guid AggregateId { get; protected set; }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.Core/PlataformaEducacao.Core.csproj b/src/building-blocks/PlataformaEducacao.Core/PlataformaEducacao.Core.csproj
index 9242cd4..cf7bd32 100644
--- a/src/building-blocks/PlataformaEducacao.Core/PlataformaEducacao.Core.csproj
+++ b/src/building-blocks/PlataformaEducacao.Core/PlataformaEducacao.Core.csproj
@@ -8,9 +8,9 @@
-
-
-
+
+
+
diff --git a/src/building-blocks/PlataformaEducacao.Core/Utils/StringUtils.cs b/src/building-blocks/PlataformaEducacao.Core/Utils/StringUtils.cs
index b6af80e..3b0f48b 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Utils/StringUtils.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Utils/StringUtils.cs
@@ -7,4 +7,4 @@ public static string ApenasNumeros(this string str, string input)
return new string(input.Where(c => char.IsDigit(c)).ToArray());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/building-blocks/PlataformaEducacao.Core/Validacoes.cs b/src/building-blocks/PlataformaEducacao.Core/Validacoes.cs
index 7f0e09d..cc3ee80 100644
--- a/src/building-blocks/PlataformaEducacao.Core/Validacoes.cs
+++ b/src/building-blocks/PlataformaEducacao.Core/Validacoes.cs
@@ -6,7 +6,7 @@ public class Validacoes
{
public static void ValidarSeVazio(string? valor, string mensagem)
{
- if (String.IsNullOrWhiteSpace(valor))
+ if (string.IsNullOrWhiteSpace(valor))
{
throw new DomainException(mensagem);
}
diff --git a/src/building-blocks/PlataformaEducacao.MessageBus/DependencyInjectionExtensions.cs b/src/building-blocks/PlataformaEducacao.MessageBus/DependencyInjectionExtensions.cs
index 8cad006..5cc495d 100644
--- a/src/building-blocks/PlataformaEducacao.MessageBus/DependencyInjectionExtensions.cs
+++ b/src/building-blocks/PlataformaEducacao.MessageBus/DependencyInjectionExtensions.cs
@@ -6,7 +6,8 @@ public static class DependencyInjectionExtensions
{
public static IServiceCollection AddMessageBus(this IServiceCollection services, string connection)
{
- if (string.IsNullOrEmpty(connection)) throw new ArgumentNullException();
+ if (string.IsNullOrEmpty(connection))
+ throw new ArgumentNullException(nameof(connection), "A conexão não pode ser nula ou vazia.");
services.AddSingleton(new MessageBus(connection));
diff --git a/src/building-blocks/PlataformaEducacao.MessageBus/IMessageBus.cs b/src/building-blocks/PlataformaEducacao.MessageBus/IMessageBus.cs
index 5c13204..8015e55 100644
--- a/src/building-blocks/PlataformaEducacao.MessageBus/IMessageBus.cs
+++ b/src/building-blocks/PlataformaEducacao.MessageBus/IMessageBus.cs
@@ -6,15 +6,20 @@ namespace PlataformaEducacao.MessageBus
public interface IMessageBus : IDisposable
{
bool IsConnected { get; }
+
IAdvancedBus AdvancedBus { get; }
- void Publish(T message) where T : IntegrationEvent;
+ void Publish(T message)
+ where T : IntegrationEvent;
- Task PublishAsync(T message) where T : IntegrationEvent;
+ Task PublishAsync(T message)
+ where T : IntegrationEvent;
- void Subscribe(string subscriptionId, Action onMessage) where T : class;
+ void Subscribe(string subscriptionId, Action onMessage)
+ where T : class;
- void SubscribeAsync(string subscriptionId, Func onMessage) where T : class;
+ void SubscribeAsync(string subscriptionId, Func onMessage)
+ where T : class;
TResponse Request(TRequest request)
where TRequest : IntegrationEvent
@@ -31,6 +36,5 @@ IDisposable Respond(Func responder)
IDisposable RespondAsync(Func> responder)
where TRequest : IntegrationEvent
where TResponse : ResponseMessage;
-
}
}
diff --git a/src/building-blocks/PlataformaEducacao.MessageBus/MessageBus.cs b/src/building-blocks/PlataformaEducacao.MessageBus/MessageBus.cs
index e45717c..289db8a 100644
--- a/src/building-blocks/PlataformaEducacao.MessageBus/MessageBus.cs
+++ b/src/building-blocks/PlataformaEducacao.MessageBus/MessageBus.cs
@@ -7,11 +7,10 @@ namespace PlataformaEducacao.MessageBus
{
public class MessageBus : IMessageBus
{
+ private readonly string _connectionString;
private IBus _bus = null!;
private IAdvancedBus _advancedBus = null!;
- private readonly string _connectionString;
-
public MessageBus(string connectionString)
{
_connectionString = connectionString;
@@ -19,33 +18,39 @@ public MessageBus(string connectionString)
}
public bool IsConnected => _bus?.IsConnected ?? false;
+
public IAdvancedBus AdvancedBus => _bus?.Advanced!;
- public void Publish(T message) where T : IntegrationEvent
+ public void Publish(T message)
+ where T : IntegrationEvent
{
TryConnect();
_bus.Publish(message);
}
- public async Task PublishAsync(T message) where T : IntegrationEvent
+ public async Task PublishAsync(T message)
+ where T : IntegrationEvent
{
TryConnect();
await _bus.PublishAsync(message);
}
- public void Subscribe(string subscriptionId, Action onMessage) where T : class
+ public void Subscribe(string subscriptionId, Action onMessage)
+ where T : class
{
TryConnect();
_bus.Subscribe(subscriptionId, onMessage);
}
- public void SubscribeAsync(string subscriptionId, Func onMessage) where T : class
+ public void SubscribeAsync(string subscriptionId, Func onMessage)
+ where T : class
{
TryConnect();
_bus.SubscribeAsync(subscriptionId, onMessage);
}
- public TResponse Request(TRequest request) where TRequest : IntegrationEvent
+ public TResponse Request(TRequest request)
+ where TRequest : IntegrationEvent
where TResponse : ResponseMessage
{
TryConnect();
@@ -53,26 +58,34 @@ public TResponse Request(TRequest request) where TRequest :
}
public async Task RequestAsync(TRequest request)
- where TRequest : IntegrationEvent where TResponse : ResponseMessage
+ where TRequest : IntegrationEvent
+ where TResponse : ResponseMessage
{
TryConnect();
return await _bus.RequestAsync(request);
}
public IDisposable Respond(Func responder)
- where TRequest : IntegrationEvent where TResponse : ResponseMessage
+ where TRequest : IntegrationEvent
+ where TResponse : ResponseMessage
{
TryConnect();
return _bus.Respond(responder);
}
public IDisposable RespondAsync(Func> responder)
- where TRequest : IntegrationEvent where TResponse : ResponseMessage
+ where TRequest : IntegrationEvent
+ where TResponse : ResponseMessage
{
TryConnect();
return _bus.RespondAsync(responder);
}
+ public void Dispose()
+ {
+ _bus.Dispose();
+ }
+
private void TryConnect()
{
if (IsConnected) return;
@@ -98,10 +111,5 @@ private void OnDisconnect(object? s, EventArgs e)
policy.Execute(TryConnect);
}
-
- public void Dispose()
- {
- _bus.Dispose();
- }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Controllers/MainController.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Controllers/MainController.cs
index d05aa04..ea148ba 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Controllers/MainController.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Controllers/MainController.cs
@@ -1,8 +1,8 @@
-using FluentValidation.Results;
+using System.Net;
+using FluentValidation.Results;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using PlataformaEducacao.Core.Communication;
-using System.Net;
namespace PlataformaEducacao.WebApi.Core.Controllers
{
@@ -91,4 +91,4 @@ protected void LimparErrosProcessamento()
Errors.Clear();
}
}
-}
\ No newline at end of file
+}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/CorsConfig.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/CorsConfig.cs
index 9d5a304..08ceb51 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/CorsConfig.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/CorsConfig.cs
@@ -12,7 +12,7 @@ public static IServiceCollection AddCorsConfiguration(
var allowedOrigins = configuration
.GetSection("Cors:AllowedOrigins")
.Get()
- ?? Array.Empty();
+ ?? [];
services.AddCors(options =>
{
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/LoggingConfig.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/LoggingConfig.cs
index 1c7373d..cf6215c 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/LoggingConfig.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/LoggingConfig.cs
@@ -7,52 +7,51 @@
using Serilog;
using Serilog.Events;
-namespace PlataformaEducacao.WebApi.Core.Extensions;
-
-
-public static class LoggingConfig
+namespace PlataformaEducacao.WebApi.Core.Extensions
{
- public static IHostBuilder AddLoggingConfiguration(
- this IHostBuilder hostBuilder,
- IConfiguration configuration,
- string serviceName)
+ public static class LoggingConfig
{
- hostBuilder.UseSerilog((context, _, loggerConfig) =>
+ public static IHostBuilder AddLoggingConfiguration(
+ this IHostBuilder hostBuilder,
+ IConfiguration configuration,
+ string serviceName)
{
- loggerConfig
- .ReadFrom.Configuration(configuration)
- .Enrich.FromLogContext()
- .Enrich.WithMachineName()
- .Enrich.WithProcessId()
- .Enrich.WithThreadId()
- .Enrich.WithProperty("Service", serviceName)
- .Enrich.WithProperty("Application", serviceName);
-
- var minimumLevel = context.Configuration["Serilog:MinimumLevel:Default"];
- if (!string.IsNullOrWhiteSpace(minimumLevel)
- && Enum.TryParse(minimumLevel, true, out LogEventLevel level))
+ hostBuilder.UseSerilog((context, _, loggerConfig) =>
{
- loggerConfig.MinimumLevel.Is(level);
- }
- });
-
- return hostBuilder;
- }
-
- public static IServiceCollection AddCorrelationIdConfiguration(
- this IServiceCollection services,
- IConfiguration configuration)
- {
- services.AddDefaultCorrelationId();
- services.Configure(configuration.GetSection("CorrelationIdOptions"));
- return services;
- }
+ loggerConfig
+ .ReadFrom.Configuration(configuration)
+ .Enrich.FromLogContext()
+ .Enrich.WithMachineName()
+ .Enrich.WithProcessId()
+ .Enrich.WithThreadId()
+ .Enrich.WithProperty("Service", serviceName)
+ .Enrich.WithProperty("Application", serviceName);
+
+ var minimumLevel = context.Configuration["Serilog:MinimumLevel:Default"];
+ if (!string.IsNullOrWhiteSpace(minimumLevel)
+ && Enum.TryParse(minimumLevel, true, out LogEventLevel level))
+ {
+ loggerConfig.MinimumLevel.Is(level);
+ }
+ });
+
+ return hostBuilder;
+ }
+
+ public static IServiceCollection AddCorrelationIdConfiguration(
+ this IServiceCollection services,
+ IConfiguration configuration)
+ {
+ services.AddDefaultCorrelationId();
+ services.Configure(configuration.GetSection("CorrelationIdOptions"));
+ return services;
+ }
- public static IApplicationBuilder UseLoggingConfiguration(this IApplicationBuilder app)
- {
- app.UseCorrelationId();
- app.UseSerilogRequestLogging();
- return app;
+ public static IApplicationBuilder UseLoggingConfiguration(this IApplicationBuilder app)
+ {
+ app.UseCorrelationId();
+ app.UseSerilogRequestLogging();
+ return app;
+ }
}
-
-}
\ No newline at end of file
+}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/PollyExtensions.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/PollyExtensions.cs
index bd518b6..3964c7c 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/PollyExtensions.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/PollyExtensions.cs
@@ -10,12 +10,12 @@ public static AsyncRetryPolicy EsperarTentar()
{
var retry = HttpPolicyExtensions
.HandleTransientHttpError()
- .WaitAndRetryAsync(new[]
- {
+ .WaitAndRetryAsync(
+ [
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(10),
- });
+ ]);
return retry;
}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/ResponseResultExtensions.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/ResponseResultExtensions.cs
index 02da714..1a4d07c 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/ResponseResultExtensions.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Extensions/ResponseResultExtensions.cs
@@ -2,15 +2,13 @@
{
public static class ResponseResultExtensions
{
- //public static async Task> ToResponseResult(this HttpResponseMessage response)
- //{
+ // public static async Task> ToResponseResult(this HttpResponseMessage response)
+ // {
// var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true };
-
// if (response.IsSuccessStatusCode)
// {
// return await response.Content.ReadFromJsonAsync>(options);
// }
-
// if (response.StatusCode == HttpStatusCode.BadRequest)
// {
// var problem = await response.Content.ReadFromJsonAsync(options);
@@ -20,8 +18,7 @@ public static class ResponseResultExtensions
// Erros = new ResponseErrorMessages { Mensagens = problem!.Errors.SelectMany(x => x.Value).ToList() }
// };
// }
-
// return new ResponseResult { Sucesso = false };
- //}
+ // }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/AppSettings.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/AppSettings.cs
index 86c9726..4ad431e 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/AppSettings.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/AppSettings.cs
@@ -3,9 +3,13 @@
public class AppSettings
{
public string Secret { get; set; } = string.Empty;
+
public int ExpiracaoHoras { get; set; }
+
public int ExpiracaoRefreshToken { get; set; }
+
public string Emissor { get; set; } = string.Empty;
+
public string ValidoEm { get; set; } = string.Empty;
}
}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/ClaimsAuthorizeAttribute.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/ClaimsAuthorizeAttribute.cs
new file mode 100644
index 0000000..3b7ac3a
--- /dev/null
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/ClaimsAuthorizeAttribute.cs
@@ -0,0 +1,16 @@
+using System.Security.Claims;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace PlataformaEducacao.WebApi.Core.Identidade
+{
+ public class ClaimsAuthorizeAttribute : TypeFilterAttribute
+ {
+ public ClaimsAuthorizeAttribute(string claimName, string claimValue)
+ : base(typeof(RequisitoClaimFilter))
+ {
+ Arguments = [new Claim(claimName, claimValue)];
+ }
+ }
+}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/CustomAuthorize.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/CustomAuthorize.cs
index d95dd89..c06fbf5 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/CustomAuthorize.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/CustomAuthorize.cs
@@ -1,7 +1,7 @@
-using Microsoft.AspNetCore.Http;
+using System.Security.Claims;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
-using System.Security.Claims;
namespace PlataformaEducacao.WebApi.Core.Identidade
{
@@ -12,38 +12,5 @@ public static bool ValidarClaimsUsuario(HttpContext context, string claimName, s
return context.User.Identity!.IsAuthenticated &&
context.User.Claims.Any(c => c.Type == claimName && c.Value.Contains(claimValue));
}
-
- }
-
- public class ClaimsAuthorizeAttribute : TypeFilterAttribute
- {
- public ClaimsAuthorizeAttribute(string claimName, string claimValue) : base(typeof(RequisitoClaimFilter))
- {
- Arguments = new object[] { new Claim(claimName, claimValue) };
- }
- }
-
- public class RequisitoClaimFilter : IAuthorizationFilter
- {
- private readonly Claim _claim;
-
- public RequisitoClaimFilter(Claim claim)
- {
- _claim = claim;
- }
-
- public void OnAuthorization(AuthorizationFilterContext context)
- {
- if (!context.HttpContext.User.Identity!.IsAuthenticated)
- {
- context.Result = new StatusCodeResult(401);
- return;
- }
-
- if (!CustomAuthorization.ValidarClaimsUsuario(context.HttpContext, _claim.Type, _claim.Value))
- {
- context.Result = new StatusCodeResult(403);
- }
- }
}
}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/JwtConfig.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/JwtConfig.cs
index b0df23e..5a7d732 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/JwtConfig.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/JwtConfig.cs
@@ -1,16 +1,16 @@
-using Microsoft.AspNetCore.Authentication.JwtBearer;
+using System.Text;
+using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
-using System.Text;
namespace PlataformaEducacao.WebApi.Core.Identidade
{
public static class JwtConfig
{
- public static IServiceCollection AddJwtConfiguration(this IServiceCollection services,
- IConfiguration configuration)
+ public static IServiceCollection AddJwtConfiguration(
+ this IServiceCollection services, IConfiguration configuration)
{
var appSettingsSection = configuration.GetSection("AppSettings");
services.Configure(appSettingsSection);
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/RequisitoClaimFilter.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/RequisitoClaimFilter.cs
new file mode 100644
index 0000000..f3a7ae7
--- /dev/null
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Identidade/RequisitoClaimFilter.cs
@@ -0,0 +1,31 @@
+using System.Security.Claims;
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.Filters;
+
+namespace PlataformaEducacao.WebApi.Core.Identidade
+{
+ public class RequisitoClaimFilter : IAuthorizationFilter
+ {
+ private readonly Claim _claim;
+
+ public RequisitoClaimFilter(Claim claim)
+ {
+ _claim = claim;
+ }
+
+ public void OnAuthorization(AuthorizationFilterContext context)
+ {
+ if (!context.HttpContext.User.Identity!.IsAuthenticated)
+ {
+ context.Result = new StatusCodeResult(401);
+ return;
+ }
+
+ if (!CustomAuthorization.ValidarClaimsUsuario(context.HttpContext, _claim.Type, _claim.Value))
+ {
+ context.Result = new StatusCodeResult(403);
+ }
+ }
+ }
+}
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/AspNetUser.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/AspNetUser.cs
index 9576522..7b7e833 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/AspNetUser.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/AspNetUser.cs
@@ -1,5 +1,5 @@
-using Microsoft.AspNetCore.Http;
-using System.Security.Claims;
+using System.Security.Claims;
+using Microsoft.AspNetCore.Http;
namespace PlataformaEducacao.WebApi.Core.Usuario
{
@@ -21,17 +21,17 @@ public Guid ObterUserId()
public string ObterUserEmail()
{
- return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserEmail() : "";
+ return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserEmail() : string.Empty;
}
public string ObterUserToken()
{
- return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserToken() : "";
+ return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserToken() : string.Empty;
}
public string ObterUserRefreshToken()
{
- return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserRefreshToken() : "";
+ return EstaAutenticado() ? _accessor.HttpContext!.User.GetUserRefreshToken() : string.Empty;
}
public bool EstaAutenticado()
diff --git a/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/IAspNetUser.cs b/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/IAspNetUser.cs
index 8254461..3ec86c1 100644
--- a/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/IAspNetUser.cs
+++ b/src/building-blocks/PlataformaEducacao.WebApi.Core/Usuario/IAspNetUser.cs
@@ -1,18 +1,26 @@
-using Microsoft.AspNetCore.Http;
-using System.Security.Claims;
+using System.Security.Claims;
+using Microsoft.AspNetCore.Http;
namespace PlataformaEducacao.WebApi.Core.Usuario
{
public interface IAspNetUser
{
string Name { get; }
+
Guid ObterUserId();
+
string ObterUserEmail();
+
string ObterUserToken();
+
string ObterUserRefreshToken();
+
bool EstaAutenticado();
+
bool PossuiRole(string role);
+
IEnumerable ObterClaims();
+
HttpContext ObterHttpContext();
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/ApiConfig.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/ApiConfig.cs
index bc1af1f..6d54fd2 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/ApiConfig.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/ApiConfig.cs
@@ -1,7 +1,7 @@
-using Microsoft.AspNetCore.HttpOverrides;
+using System.Text.Json.Serialization;
+using Microsoft.AspNetCore.HttpOverrides;
using PlataformaEducacao.WebApi.Core.Extensions;
using PlataformaEducacao.WebApi.Core.Identidade;
-using System.Text.Json.Serialization;
namespace PlataformaEducacao.GestaoAluno.Api.Configurations
{
@@ -21,6 +21,7 @@ public static IHostBuilder ConfigureAppSettings(this IHostBuilder host)
return host;
}
+
public static IServiceCollection AddApiConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddControllers()
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbContextConfig.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbContextConfig.cs
index 2ddc1cd..65ae60f 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbContextConfig.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbContextConfig.cs
@@ -23,6 +23,7 @@ public static IServiceCollection AddDbContextConfig(this IServiceCollection serv
opt.EnableSensitiveDataLogging();
});
}
+
return services;
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbMigrationHelper.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbMigrationHelper.cs
index a452e6a..719d845 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbMigrationHelper.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DbMigrationHelper.cs
@@ -18,6 +18,7 @@ public static async Task EnsureSeedData(WebApplication application)
var service = application.Services.CreateScope().ServiceProvider;
await EnsureSeedData(service);
}
+
public static async Task EnsureSeedData(IServiceProvider serviceProvider)
{
using var scope = serviceProvider.GetRequiredService().CreateScope();
@@ -30,28 +31,29 @@ public static async Task EnsureSeedData(IServiceProvider serviceProvider)
await alunoContext.Database.EnsureCreatedAsync();
await SeedTablesGestaoAluno(alunoContext);
}
- else if (env.EnvironmentName == "Development" || env.EnvironmentName == "Docker")
+ else if (env.EnvironmentName is "Development" or "Docker")
{
await alunoContext.Database.MigrateAsync();
await SeedTablesGestaoAluno(alunoContext);
}
}
+
private static async Task SeedTablesGestaoAluno(GestaoAlunoContext alunoContext)
{
if (!alunoContext.Matriculas.Any())
{
- Guid alunoUm = Guid.Parse("37e95975-6489-4323-8d2c-72cc91a5e3aa");
+ var alunoUm = Guid.Parse("37e95975-6489-4323-8d2c-72cc91a5e3aa");
var aluno = new Aluno(alunoUm, "Aluno ", "aluno@teste.com");
- Guid cursoId = Guid.Parse("683C31AE-7DB1-4A89-B011-13076E794824");
+ var cursoId = Guid.Parse("683C31AE-7DB1-4A89-B011-13076E794824");
var cursoNome = ".NET";
var matricula = new Matricula(cursoId, cursoNome, 5, 500);
- Guid cursoCoreId = Guid.Parse("2194EB04-6C17-4379-8F07-C847C899466F");
+ var cursoCoreId = Guid.Parse("2194EB04-6C17-4379-8F07-C847C899466F");
var cursoCoreNome = ".NET Core";
var matriculaCore = new Matricula(cursoCoreId, cursoCoreNome, 1, 500);
- Guid cursoDominiosRicosId = Guid.Parse("12E04CBC-6ACF-4582-9345-C74B12C8183C");
+ var cursoDominiosRicosId = Guid.Parse("12E04CBC-6ACF-4582-9345-C74B12C8183C");
var cursoDominiosRicosNome = "Dominios Ricos";
var matriculaDominiosRicos = new Matricula(cursoDominiosRicosId, cursoDominiosRicosNome, 1, 500);
@@ -60,10 +62,10 @@ private static async Task SeedTablesGestaoAluno(GestaoAlunoContext alunoContext)
aluno.RealizarMatricula(matriculaDominiosRicos);
matricula.Ativar();
+
// matriculaCore.Ativar(); // deixada pendente de pagamento, para já aparecer na listagem de pendentes
matriculaDominiosRicos.Ativar();
-
var progresso = new ProgressoAula(Guid.Parse("C862D7FB-341D-476F-A978-98CBD44C2D08"));
matricula.RegistrarAula(progresso);
progresso = new ProgressoAula(Guid.Parse("0E7EF4C0-4EB3-4C05-B61F-968D114C21DC"));
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DependencyInjectionConfig.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DependencyInjectionConfig.cs
index a9823c4..7b55a4b 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DependencyInjectionConfig.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/DependencyInjectionConfig.cs
@@ -21,12 +21,10 @@ public static class DependencyInjectionConfig
{
public static IServiceCollection RegisterServices(this IServiceCollection services)
{
-
// Mediator
services.AddMediatR(
typeof(AdicionarAlunoCommand).Assembly,
- typeof(AdicionarAlunoCommandHandler).Assembly
- );
+ typeof(AdicionarAlunoCommandHandler).Assembly);
// API
services.AddSingleton();
@@ -47,10 +45,10 @@ public static IServiceCollection RegisterServices(this IServiceCollection servic
services.AddScoped();
services.AddScoped();
- services.AddScoped, MatriculaEventHandler>();
- services.AddScoped, MatriculaEventHandler>();
+ services.AddScoped, MatriculaNotificationHandler>();
+ services.AddScoped, MatriculaNotificationHandler>();
return services;
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/MessageBusConfig.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/MessageBusConfig.cs
index 4f41b4b..cdb0273 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/MessageBusConfig.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/MessageBusConfig.cs
@@ -6,7 +6,8 @@ namespace PlataformaEducacao.GestaoAluno.Api.Configurations
{
public static class MessageBusConfig
{
- public static IServiceCollection AddMessageBusConfiguration(this IServiceCollection services,
+ public static IServiceCollection AddMessageBusConfiguration(
+ this IServiceCollection services,
IConfiguration configuration)
{
services.AddMessageBus(configuration.GetMessageQueueConnection("MessageBus"))
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/SwaggerConfig.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/SwaggerConfig.cs
index 10df5a9..46e05d4 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/SwaggerConfig.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Configurations/SwaggerConfig.cs
@@ -32,11 +32,11 @@ public static IServiceCollection AddSwaggerConfiguration(this IServiceCollection
{
Reference = new OpenApiReference
{
- Type=ReferenceType.SecurityScheme,
- Id="Bearer"
+ Type = ReferenceType.SecurityScheme,
+ Id = "Bearer"
}
},
- new string[]{}
+ Array.Empty()
}
});
});
@@ -52,7 +52,6 @@ public static IApplicationBuilder UseSwaggerConfiguration(this IApplicationBuild
o.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
});
-
return app;
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Controllers/AlunosController.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Controllers/AlunosController.cs
index 71e0f88..52367d0 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Controllers/AlunosController.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Controllers/AlunosController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Authorization;
+using System.Net;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PlataformaEducacao.Core.Mediator;
using PlataformaEducacao.GestaoAluno.Application.Commands.FinalizarCurso;
@@ -9,7 +10,6 @@
using PlataformaEducacao.GestaoAluno.Application.Queries.ViewModels;
using PlataformaEducacao.WebApi.Core.Controllers;
using PlataformaEducacao.WebApi.Core.Usuario;
-using System.Net;
namespace PlataformaEducacao.GestaoAluno.Api.Controllers
{
@@ -20,9 +20,10 @@ public class AlunosController : MainController
private readonly IAspNetUser _user;
private readonly IMediatorHandler _mediatorHandler;
- public AlunosController(IAlunoQueries alunoQueries,
- IAspNetUser user,
- IMediatorHandler mediatorHandler)
+ public AlunosController(
+ IAlunoQueries alunoQueries,
+ IAspNetUser user,
+ IMediatorHandler mediatorHandler)
{
_alunoQueries = alunoQueries;
_user = user;
@@ -97,6 +98,7 @@ public async Task BaixarCertificado(Guid certificadoId, Cancellati
AdicionarErroProcessamento("Certificado não encontrado.");
return CustomResponse();
}
+
return File(certificado.PdfBytes, certificado.ContentType, certificado.NomeArquivo);
}
@@ -121,7 +123,8 @@ public async Task> ObterHistoricoAluno(Gui
AdicionarErroProcessamento("Histórico de aluno não encontrado.");
return CustomResponse();
}
+
return CustomResponse(HttpStatusCode.OK, historicoAluno);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Program.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Program.cs
index f61a6d8..ab84c94 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Program.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Program.cs
@@ -1,7 +1,7 @@
-using QuestPDF.Infrastructure;
using PlataformaEducacao.GestaoAluno.Api.Configurations;
using PlataformaEducacao.WebApi.Core.Extensions;
using PlataformaEducacao.WebApi.Core.Identidade;
+using QuestPDF.Infrastructure;
var builder = WebApplication.CreateBuilder(args);
@@ -30,4 +30,6 @@
app.Run();
-public partial class Program { }
+public partial class Program
+{
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Requests/MatricularRequest.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Requests/MatricularRequest.cs
index 882793a..1249088 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Requests/MatricularRequest.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Api/Requests/MatricularRequest.cs
@@ -6,10 +6,13 @@ public class MatricularRequest
{
[Required(ErrorMessage = "O curso é obrigatório.")]
public Guid CursoId { get; set; }
+
[Required(ErrorMessage = "O nome do curso é obrigatório.")]
public string NomeCurso { get; set; } = string.Empty;
+
[Required(ErrorMessage = "A quantidade de aulas do curso é obrigatório.")]
public int QuantidadeAulasCurso { get; set; }
+
[Required(ErrorMessage = "O valor do curso é obrigatório.")]
public decimal ValorCurso { get; set; }
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommand.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommand.cs
index ee76dc3..dc1d505 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommand.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommand.cs
@@ -13,7 +13,9 @@ public AdicionarAlunoCommand(Guid usuarioId, string nome, string email)
}
public Guid UsuarioId { get; private set; }
+
public string Nome { get; private set; }
+
public string Email { get; private set; }
public override bool EhValido()
@@ -22,22 +24,4 @@ public override bool EhValido()
return ValidationResult.IsValid;
}
}
-
- public class AdicionarAlunoCommandValidation : AbstractValidator
- {
- public AdicionarAlunoCommandValidation()
- {
- RuleFor(a => a.UsuarioId)
- .NotEmpty()
- .WithMessage("O id do usuário é obrigatório.");
-
- RuleFor(a => a.Nome)
- .NotEmpty()
- .WithMessage("O nome do aluno é obrigatório.");
-
- RuleFor(a => a.Email)
- .NotEmpty()
- .WithMessage("O e-mail do aluno é obrigatório.");
- }
- }
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandHandler.cs
index 5e5899a..2ce09c0 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandHandler.cs
@@ -16,11 +16,11 @@ public AdicionarAlunoCommandHandler(IAlunoRepository alunoRepository)
_alunoRepository = alunoRepository;
}
- public async Task Handle(AdicionarAlunoCommand message, CancellationToken cancellationToken)
+ public async Task Handle(AdicionarAlunoCommand request, CancellationToken cancellationToken)
{
- if (!message.EhValido()) return message.ValidationResult;
+ if (!request.EhValido()) return request.ValidationResult;
- var aluno = new Aluno(message.UsuarioId, message.Nome, message.Email);
+ var aluno = new Aluno(request.UsuarioId, request.Nome, request.Email);
await _alunoRepository.Inserir(aluno, cancellationToken);
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandValidation.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandValidation.cs
new file mode 100644
index 0000000..75357e1
--- /dev/null
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/AdicionarAluno/AdicionarAlunoCommandValidation.cs
@@ -0,0 +1,23 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoAluno.Application.Commands.AdicionarAluno
+{
+ public class AdicionarAlunoCommandValidation : AbstractValidator
+ {
+ public AdicionarAlunoCommandValidation()
+ {
+ RuleFor(a => a.UsuarioId)
+ .NotEmpty()
+ .WithMessage("O id do usuário é obrigatório.");
+
+ RuleFor(a => a.Nome)
+ .NotEmpty()
+ .WithMessage("O nome do aluno é obrigatório.");
+
+ RuleFor(a => a.Email)
+ .NotEmpty()
+ .WithMessage("O e-mail do aluno é obrigatório.");
+ }
+ }
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommand.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommand.cs
index 13dd5b7..dee731c 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommand.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommand.cs
@@ -18,14 +18,4 @@ public override bool EhValido()
return ValidationResult.IsValid;
}
}
-
- public class FinalizarCursoCommandValidation : AbstractValidator
- {
- public FinalizarCursoCommandValidation()
- {
- RuleFor(c => c.MatriculaId)
- .NotEqual(Guid.Empty)
- .WithMessage("Id da matrícula inválido.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandHandler.cs
index 2790b61..e4fc3cc 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandHandler.cs
@@ -16,20 +16,20 @@ public FinalizarCursoCommandHandler(IAlunoRepository alunoRepository)
_alunoRepository = alunoRepository;
}
- public async Task Handle(FinalizarCursoCommand message, CancellationToken cancellationToken)
+ public async Task Handle(FinalizarCursoCommand request, CancellationToken cancellationToken)
{
- if (message.EhValido() is false) return message.ValidationResult;
+ if (request.EhValido() is false) return request.ValidationResult;
- var matricula = await _alunoRepository.ObterMatriculaComProgressoAulasPorId(message.MatriculaId, cancellationToken);
+ var matricula = await _alunoRepository.ObterMatriculaComProgressoAulasPorId(request.MatriculaId, cancellationToken);
if (matricula is null)
{
- AdicionarErro($"Matrícula {message.MatriculaId} não encontrada.");
+ AdicionarErro($"Matrícula {request.MatriculaId} não encontrada.");
return ValidationResult;
}
if (matricula.EstaAtiva() is false)
{
- AdicionarErro($"Matrícula {message.MatriculaId} pendente de pagamento.");
+ AdicionarErro($"Matrícula {request.MatriculaId} pendente de pagamento.");
return ValidationResult;
}
@@ -50,4 +50,4 @@ public async Task Handle(FinalizarCursoCommand message, Cancel
return await PersistirDados(_alunoRepository.UnitOfWork);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandValidation.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandValidation.cs
new file mode 100644
index 0000000..d45e9af
--- /dev/null
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/FinalizarCurso/FinalizarCursoCommandValidation.cs
@@ -0,0 +1,15 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoAluno.Application.Commands.FinalizarCurso
+{
+ public class FinalizarCursoCommandValidation : AbstractValidator
+ {
+ public FinalizarCursoCommandValidation()
+ {
+ RuleFor(c => c.MatriculaId)
+ .NotEqual(Guid.Empty)
+ .WithMessage("Id da matrícula inválido.");
+ }
+ }
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommand.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommand.cs
index 8a5d28d..e49a024 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommand.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommand.cs
@@ -12,14 +12,4 @@ public GerarCertificadoCommand(Guid matriculaId)
MatriculaId = matriculaId;
}
}
-
- public class GerarCertificadoCommandValidation : AbstractValidator
- {
- public GerarCertificadoCommandValidation()
- {
- RuleFor(c => c.MatriculaId)
- .NotEqual(Guid.Empty)
- .WithMessage("Id da matrícula inválido.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandHandler.cs
index eacc042..5f31a81 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandHandler.cs
@@ -14,9 +14,10 @@ public GerarCertificadoCommandHandler(IAlunoRepository alunoRepository)
{
_alunoRepository = alunoRepository;
}
- public async Task Handle(GerarCertificadoCommand message, CancellationToken cancellationToken)
+
+ public async Task Handle(GerarCertificadoCommand request, CancellationToken cancellationToken)
{
- var matricula = await _alunoRepository.ObterMatriculaComCertificadoPorId(message.MatriculaId, cancellationToken);
+ var matricula = await _alunoRepository.ObterMatriculaComCertificadoPorId(request.MatriculaId, cancellationToken);
matricula?.GerarCertificado();
await _alunoRepository.GerarCertificado(matricula!.Certificado!, cancellationToken);
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandValidation.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandValidation.cs
new file mode 100644
index 0000000..1cc01cc
--- /dev/null
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/GerarCertificado/GerarCertificadoCommandValidation.cs
@@ -0,0 +1,15 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoAluno.Application.Commands.GerarCertificado
+{
+ public class GerarCertificadoCommandValidation : AbstractValidator
+ {
+ public GerarCertificadoCommandValidation()
+ {
+ RuleFor(c => c.MatriculaId)
+ .NotEqual(Guid.Empty)
+ .WithMessage("Id da matrícula inválido.");
+ }
+ }
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommand.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommand.cs
index 7a4fe9c..d4b119c 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommand.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommand.cs
@@ -6,9 +6,13 @@ namespace PlataformaEducacao.GestaoAluno.Application.Commands.MatricularAlunoCur
public class MatricularAlunoCursoCommand : Command
{
public Guid CursoId { get; private set; }
+
public Guid AlunoId { get; private set; }
+
public string NomeCurso { get; private set; }
+
public decimal Valor { get; private set; }
+
public int TotalAulasCurso { get; private set; }
public MatricularAlunoCursoCommand(Guid cursoId, Guid alunoId, string nomeCurso, int totalAulasCurso, decimal valor)
@@ -31,30 +35,4 @@ public void VincularAluno(Guid guid)
AlunoId = guid;
}
}
-
- public class MatricularAlunoCursoCommandValidation : AbstractValidator
- {
- public MatricularAlunoCursoCommandValidation()
- {
- RuleFor(a => a.AlunoId)
- .NotEmpty()
- .WithMessage("O id do aluno é obrigatório.");
-
- RuleFor(a => a.CursoId)
- .NotEmpty()
- .WithMessage("O id do curso é obrigatório.");
-
- RuleFor(a => a.NomeCurso)
- .NotEmpty()
- .WithMessage("O nome do curso é obrigatório.");
-
- RuleFor(c => c.Valor)
- .GreaterThan(0)
- .WithMessage("O valor do curso deve ser maior que 0.");
-
- RuleFor(a => a.TotalAulasCurso)
- .GreaterThan(0)
- .WithMessage("O número de aulas do curso é obrigatório.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandHandler.cs
index 1cea388..e4b4d83 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandHandler.cs
@@ -16,18 +16,18 @@ public MatricularAlunoCursoCommandHandler(IAlunoRepository alunoRepository)
_alunoRepository = alunoRepository;
}
- public async Task Handle(MatricularAlunoCursoCommand message, CancellationToken cancellationToken)
+ public async Task Handle(MatricularAlunoCursoCommand request, CancellationToken cancellationToken)
{
- if (message.EhValido() is false) return message.ValidationResult;
+ if (request.EhValido() is false) return request.ValidationResult;
- var aluno = await _alunoRepository.ObterComMatriculasPorId(message.AlunoId, cancellationToken);
+ var aluno = await _alunoRepository.ObterComMatriculasPorId(request.AlunoId, cancellationToken);
if (aluno is null)
{
AdicionarErro("Aluno não encontrado!");
return ValidationResult;
}
- var matricula = new Matricula(message.CursoId, message.NomeCurso, message.TotalAulasCurso, message.Valor);
+ var matricula = new Matricula(request.CursoId, request.NomeCurso, request.TotalAulasCurso, request.Valor);
if (aluno.MatriculaExistente(matricula))
{
AdicionarErro("Aluno já matriculado no curso!");
@@ -41,4 +41,4 @@ public async Task Handle(MatricularAlunoCursoCommand message,
return await PersistirDados(_alunoRepository.UnitOfWork);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandValidation.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandValidation.cs
new file mode 100644
index 0000000..2cdccf3
--- /dev/null
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/MatricularAlunoCurso/MatricularAlunoCursoCommandValidation.cs
@@ -0,0 +1,31 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoAluno.Application.Commands.MatricularAlunoCurso
+{
+ public class MatricularAlunoCursoCommandValidation : AbstractValidator
+ {
+ public MatricularAlunoCursoCommandValidation()
+ {
+ RuleFor(a => a.AlunoId)
+ .NotEmpty()
+ .WithMessage("O id do aluno é obrigatório.");
+
+ RuleFor(a => a.CursoId)
+ .NotEmpty()
+ .WithMessage("O id do curso é obrigatório.");
+
+ RuleFor(a => a.NomeCurso)
+ .NotEmpty()
+ .WithMessage("O nome do curso é obrigatório.");
+
+ RuleFor(c => c.Valor)
+ .GreaterThan(0)
+ .WithMessage("O valor do curso deve ser maior que 0.");
+
+ RuleFor(a => a.TotalAulasCurso)
+ .GreaterThan(0)
+ .WithMessage("O número de aulas do curso é obrigatório.");
+ }
+ }
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommand.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommand.cs
index 28eafc0..9c5bb04 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommand.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommand.cs
@@ -6,7 +6,9 @@ namespace PlataformaEducacao.GestaoAluno.Application.Commands.RealizarAula
public class RealizarAulaCommand : Command
{
public Guid MatriculaId { get; private set; }
+
public Guid CursoId { get; private set; }
+
public Guid AulaId { get; private set; }
public RealizarAulaCommand(Guid matriculaId, Guid cursoId, Guid aulaId)
@@ -22,22 +24,4 @@ public override bool EhValido()
return ValidationResult.IsValid;
}
}
-
- public class RealizarAulaCommandValidation : AbstractValidator
- {
- public RealizarAulaCommandValidation()
- {
- RuleFor(c => c.AulaId)
- .NotEqual(Guid.Empty)
- .WithMessage("Id da aula inválido.");
-
- RuleFor(c => c.MatriculaId)
- .NotEqual(Guid.Empty)
- .WithMessage("Id da matrícula inválido.");
-
- RuleFor(c => c.CursoId)
- .NotEqual(Guid.Empty)
- .WithMessage("Id do curso inválido.");
- }
- }
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandHandler.cs
index 6cf0177..28a26ae 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandHandler.cs
@@ -16,11 +16,11 @@ public RealizarAulaCommandHandler(IAlunoRepository alunoRepository)
_alunoRepository = alunoRepository;
}
- public async Task Handle(RealizarAulaCommand message, CancellationToken cancellationToken)
+ public async Task Handle(RealizarAulaCommand request, CancellationToken cancellationToken)
{
- if (message.EhValido() is false) return message.ValidationResult;
+ if (request.EhValido() is false) return request.ValidationResult;
- var matricula = await _alunoRepository.ObterMatriculaComProgressoAulasPorId(message.MatriculaId, cancellationToken);
+ var matricula = await _alunoRepository.ObterMatriculaComProgressoAulasPorId(request.MatriculaId, cancellationToken);
if (matricula is null)
{
AdicionarErro("Matrícula não encontrada.");
@@ -33,13 +33,13 @@ public async Task Handle(RealizarAulaCommand message, Cancella
return ValidationResult;
}
- if (matricula.CursoId != message.CursoId)
+ if (matricula.CursoId != request.CursoId)
{
AdicionarErro("Essa aula não faz parte do curso dessa matrícula.");
return ValidationResult;
}
- var progressoAula = new ProgressoAula(message.AulaId);
+ var progressoAula = new ProgressoAula(request.AulaId);
if (matricula.AulaRealizada(progressoAula))
{
AdicionarErro("Aula já realizada.");
@@ -54,4 +54,4 @@ public async Task Handle(RealizarAulaCommand message, Cancella
return await PersistirDados(_alunoRepository.UnitOfWork);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandValidation.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandValidation.cs
new file mode 100644
index 0000000..aa96380
--- /dev/null
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Commands/RealizarAula/RealizarAulaCommandValidation.cs
@@ -0,0 +1,23 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoAluno.Application.Commands.RealizarAula
+{
+ public class RealizarAulaCommandValidation : AbstractValidator
+ {
+ public RealizarAulaCommandValidation()
+ {
+ RuleFor(c => c.AulaId)
+ .NotEqual(Guid.Empty)
+ .WithMessage("Id da aula inválido.");
+
+ RuleFor(c => c.MatriculaId)
+ .NotEqual(Guid.Empty)
+ .WithMessage("Id da matrícula inválido.");
+
+ RuleFor(c => c.CursoId)
+ .NotEqual(Guid.Empty)
+ .WithMessage("Id do curso inválido.");
+ }
+ }
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/ArquivoDTO.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/ArquivoDTO.cs
index 8baa788..929b96b 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/ArquivoDTO.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/ArquivoDTO.cs
@@ -3,7 +3,9 @@
public class ArquivoDTO
{
public byte[] PdfBytes { get; set; } = null!;
+
public string ContentType { get; set; } = null!;
+
public string NomeArquivo { get; set; } = null!;
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/CertificadoDTO.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/CertificadoDTO.cs
index 6e91416..7539631 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/CertificadoDTO.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/CertificadoDTO.cs
@@ -6,13 +6,20 @@ public class CertificadoDTO(Guid certificadoId, string nomeAluno, string nomeCur
string codigoVerificacao)
{
public Guid CertificadoId { get; set; } = certificadoId;
+
public string NomeAluno { get; set; } = nomeAluno;
+
public string NomeCurso { get; set; } = nomeCurso;
+
public DateTime DataConclusao { get; set; } = dataConclusao;
+
public string CodigoVerificacao { get; set; } = codigoVerificacao;
- public static CertificadoDTO FromMatricula(Matricula m) => new(m.Certificado!.Id,
- m.Aluno.Nome, m.NomeCurso, m.HistoricoAprendizado.DataConclusao!.Value,
- m.Certificado!.CodigoVerificacao);
+ public static CertificadoDTO FromMatricula(Matricula m) => new(
+ m.Certificado!.Id,
+ m.Aluno.Nome,
+ m.NomeCurso,
+ m.HistoricoAprendizado.DataConclusao!.Value,
+ m.Certificado!.CodigoVerificacao);
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaAtivaDTO.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaAtivaDTO.cs
index 0833b69..847bcf5 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaAtivaDTO.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaAtivaDTO.cs
@@ -7,22 +7,42 @@ public class MatriculaAtivaDTO(Guid matriculaId, Guid alunoId, string? nomeAluno
DateTime? dataConclusao, double progressoGeralCurso, Guid? certificadoId, string? codigoVerificacao)
{
public Guid MatriculaId { get; set; } = matriculaId;
+
public Guid AlunoId { get; set; } = alunoId;
+
public string NomeAluno { get; set; } = nomeAluno ?? string.Empty;
+
public Guid CursoId { get; set; } = cursoId;
+
public string NomeCurso { get; set; } = nomeCurso;
+
public DateTime DataMatricula { get; set; } = dataMatricula;
+
public int SituacaoMatricula { get; set; } = situacaoMatricula;
+
public int SituacaoCurso { get; set; } = situacaoCurso;
+
public DateTime? DataConclusao { get; set; } = dataConclusao;
+
public double ProgressoGeralCurso { get; set; } = progressoGeralCurso;
+
public Guid? CertificadoId { get; set; } = certificadoId;
+
public string? CodigoVerificacao { get; set; } = codigoVerificacao;
public static MatriculaAtivaDTO FromMatricula(Matricula m)
- => new(m.Id, m.AlunoId, m.Aluno.Nome, m.CursoId, m.NomeCurso, (int)m.SituacaoMatricula,
- m.DataMatricula, (int)m.HistoricoAprendizado.SituacaoCurso,
- m.HistoricoAprendizado.DataConclusao, m.HistoricoAprendizado.ProgressoGeralCurso,
- m.Certificado?.Id, m.Certificado?.CodigoVerificacao);
+ => new(
+ m.Id,
+ m.AlunoId,
+ m.Aluno.Nome,
+ m.CursoId,
+ m.NomeCurso,
+ (int)m.SituacaoMatricula,
+ m.DataMatricula,
+ (int)m.HistoricoAprendizado.SituacaoCurso,
+ m.HistoricoAprendizado.DataConclusao,
+ m.HistoricoAprendizado.ProgressoGeralCurso,
+ m.Certificado?.Id,
+ m.Certificado?.CodigoVerificacao);
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaPendentePagamentoDTO.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaPendentePagamentoDTO.cs
index c843da1..522ce3f 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaPendentePagamentoDTO.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/DTO/MatriculaPendentePagamentoDTO.cs
@@ -6,13 +6,18 @@ public class MatriculaPendentePagamentoDTO(Guid matriculaId, Guid alunoId, strin
Guid cursoId, string nomeCurso, DateTime dataMatricula)
{
public Guid MatriculaId { get; set; } = matriculaId;
+
public Guid AlunoId { get; set; } = alunoId;
+
public string NomeAluno { get; set; } = nomeAluno ?? string.Empty;
+
public Guid CursoId { get; set; } = cursoId;
+
public string NomeCurso { get; set; } = nomeCurso;
+
public DateTime DataMatricula { get; set; } = dataMatricula;
public static MatriculaPendentePagamentoDTO FromMatricula(Matricula m)
=> new(m.Id, m.AlunoId, m.Aluno.Nome, m.CursoId, m.NomeCurso, m.DataMatricula);
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaEventHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaNotificationHandler.cs
similarity index 69%
rename from src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaEventHandler.cs
rename to src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaNotificationHandler.cs
index c4f9974..af96e89 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaEventHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Events/MatriculaNotificationHandler.cs
@@ -5,23 +5,25 @@
namespace PlataformaEducacao.GestaoAluno.Application.Events
{
- public class MatriculaEventHandler :
+ public class MatriculaNotificationHandler :
INotificationHandler,
INotificationHandler
{
private readonly IMediatorHandler _mediatorHandler;
- public MatriculaEventHandler(IMediatorHandler mediatorHandler)
+ public MatriculaNotificationHandler(IMediatorHandler mediatorHandler)
{
_mediatorHandler = mediatorHandler;
}
- public async Task Handle(CursoFinalizadoEvent message, CancellationToken cancellationToken)
+
+ public async Task Handle(CursoFinalizadoEvent notification, CancellationToken cancellationToken)
{
- await _mediatorHandler.SendCommand(new GerarCertificadoCommand(message.MatriculaId));
+ await _mediatorHandler.SendCommand(new GerarCertificadoCommand(notification.MatriculaId));
}
+
public Task Handle(MatriculaAtivadaEvent notification, CancellationToken cancellationToken)
{
- //envio de email de boas vindas
+ // envio de email de boas vindas
return Task.CompletedTask;
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/AlunoQueries.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/AlunoQueries.cs
index 7d02493..152853b 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/AlunoQueries.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/AlunoQueries.cs
@@ -16,11 +16,11 @@ public AlunoQueries(IAlunoRepository alunoRepository, ICertificadoService certif
_certificadoService = certificadoService;
}
- public async Task> ListarMatriculasPendentesPagamentoPorAlunoId
- (Guid alunoId, CancellationToken cancellationToken)
+ public async Task> ListarMatriculasPendentesPagamentoPorAlunoId(
+ Guid alunoId, CancellationToken cancellationToken)
{
- var matriculas = await _alunoRepository.ListarMatriculasPendentesPagamentoPorAlunoId
- (alunoId, cancellationToken);
+ var matriculas = await _alunoRepository.ListarMatriculasPendentesPagamentoPorAlunoId(
+ alunoId, cancellationToken);
return matriculas.Select(m => MatriculaPendentePagamentoDTO.FromMatricula(m));
}
@@ -68,7 +68,7 @@ public async Task> ObterMatriculasAtivasPorAlunoI
if (certificado is null)
return null;
- var certificadoArquivo = await _certificadoService.GerarCertificado(certificado!);
+ var certificadoArquivo = await _certificadoService.GerarCertificado(certificado);
return new ArquivoDTO
{
@@ -85,4 +85,4 @@ public async Task> ObterMatriculasAtivasPorAlunoI
return alunoComMatriculas is null ? null : HistoricoAlunoViewModel.FromAlunoComMatriculas(alunoComMatriculas);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/IAlunoQueries.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/IAlunoQueries.cs
index fd2df58..a82a804 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/IAlunoQueries.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/IAlunoQueries.cs
@@ -6,12 +6,19 @@ namespace PlataformaEducacao.GestaoAluno.Application.Queries
public interface IAlunoQueries
{
Task ObterMatricula(Guid matriculaId, CancellationToken cancellationToken);
+
Task> ListarMatriculasPendentesPagamentoPorAlunoId(Guid alunoId, CancellationToken cancellationToken);
+
Task> ObterMatriculasAtivasPorAlunoId(Guid alunoId, CancellationToken cancellationToken);
+
Task> ObterAlunosMatriculadosPorCursoId(Guid cursoId, CancellationToken cancellationToken);
+
Task> ObterAlunosPendentesPorCursoId(Guid cursoId, CancellationToken cancellationToken);
+
Task ValidarCertificado(string codigoVerificacao, CancellationToken cancellationToken);
+
Task BaixarCertificado(Guid certificadoId, CancellationToken cancellationToken);
+
Task ObterHistoricoAluno(Guid alunoId, CancellationToken cancellationToken);
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/CursoConcluidoViewModel.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/CursoConcluidoViewModel.cs
index 3902273..1d74a99 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/CursoConcluidoViewModel.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/CursoConcluidoViewModel.cs
@@ -5,10 +5,12 @@ namespace PlataformaEducacao.GestaoAluno.Application.Queries.ViewModels
public class CursoConcluidoViewModel
{
public string NomeCurso { get; set; } = string.Empty;
+
public DateTime DataMatricula { get; set; }
+
public DateTime? DataConclusao { get; set; }
- public CursoConcluidoViewModel(String nomeCurso, DateTime dataMatricula, DateTime? dataConclusao)
+ public CursoConcluidoViewModel(string nomeCurso, DateTime dataMatricula, DateTime? dataConclusao)
{
NomeCurso = nomeCurso;
DataMatricula = dataMatricula;
@@ -21,4 +23,4 @@ public static CursoConcluidoViewModel FromMatricula(Matricula matricula)
matricula.DataMatricula,
matricula.HistoricoAprendizado.DataConclusao);
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/HistoricoAlunoViewModel.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/HistoricoAlunoViewModel.cs
index fe0123c..76ee810 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/HistoricoAlunoViewModel.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/HistoricoAlunoViewModel.cs
@@ -8,7 +8,7 @@ public class HistoricoAlunoViewModel
public IEnumerable CursosConcluidos { get; set; } = new List();
- public HistoricoAlunoViewModel(String nomeAluno, IEnumerable cursosConcluidos)
+ public HistoricoAlunoViewModel(string nomeAluno, IEnumerable cursosConcluidos)
{
NomeAluno = nomeAluno;
CursosConcluidos = cursosConcluidos;
@@ -21,4 +21,4 @@ public static HistoricoAlunoViewModel FromAlunoComMatriculas(Aluno alunoComMatri
.Where(m => m.HistoricoAprendizado.SituacaoCurso == SituacaoCurso.Concluido)
.Select(m => CursoConcluidoViewModel.FromMatricula(m)));
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/MatriculaViewModel.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/MatriculaViewModel.cs
index 2b1f1ad..38099cb 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/MatriculaViewModel.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Queries/ViewModels/MatriculaViewModel.cs
@@ -21,16 +21,27 @@ public MatriculaViewModel(Guid matriculaId, Guid alunoId, string? nomeAluno, Gui
}
public Guid MatriculaId { get; set; }
+
public Guid AlunoId { get; set; }
+
public string NomeAluno { get; set; } = null!;
+
public Guid CursoId { get; set; }
+
public string NomeCurso { get; set; } = null!;
+
public SituacaoMatricula SituacaoMatricula { get; set; }
+
public SituacaoCurso SituacaoCurso { get; set; }
+
public DateTime? DataConclusao { get; set; }
+
public double ProgressoGeralCurso { get; set; }
+
public DateTime DataMatricula { get; set; }
+
public Guid? CertificadoId { get; set; }
+
public string? CodigoVerificacao { get; set; }
public static MatriculaViewModel FromMatricula(Matricula matricula)
@@ -46,7 +57,6 @@ public static MatriculaViewModel FromMatricula(Matricula matricula)
matricula.HistoricoAprendizado.DataConclusao,
matricula.HistoricoAprendizado.ProgressoGeralCurso,
matricula.Certificado?.Id,
- matricula.Certificado?.CodigoVerificacao
- );
+ matricula.Certificado?.CodigoVerificacao);
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/PagamentoMatriculaIntegrationHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/PagamentoMatriculaIntegrationHandler.cs
index ebe7634..5e2fe39 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/PagamentoMatriculaIntegrationHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/PagamentoMatriculaIntegrationHandler.cs
@@ -26,25 +26,25 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken)
private void SetSubscribers()
{
- _bus.SubscribeAsync("MatriculaRecusada",
- async request => await RecusarMatricula(request));
+ _bus.SubscribeAsync(
+ "MatriculaRecusada", async request => await RecusarMatricula(request));
- _bus.SubscribeAsync("MatriculaConfirmada",
- async request => await FinalizarMatricula(request));
+ _bus.SubscribeAsync(
+ "MatriculaConfirmada", async request => await FinalizarMatricula(request));
}
private async Task RecusarMatricula(MatriculaPagamentoRecusadoIntegrationEvent message)
{
using var scope = _serviceProvider.CreateScope();
- var _alunoRepository = scope.ServiceProvider.GetRequiredService();
+ var alunoRepository = scope.ServiceProvider.GetRequiredService();
- var matricula = await _alunoRepository.ObterMatriculaComAlunoPorId(message.MatriculaId, default)
+ var matricula = await alunoRepository.ObterMatriculaComAlunoPorId(message.MatriculaId, default)
?? throw new DomainException($"Matrícula {message.MatriculaId} não encontrada.");
matricula.Aluno.RecusarPagamentoMatricula(matricula);
- if (await _alunoRepository.UnitOfWork.Commit() is false)
+ if (await alunoRepository.UnitOfWork.Commit() is false)
throw new DomainException($"Problemas ao cancelar a matrícula {message.MatriculaId}");
}
@@ -52,15 +52,15 @@ private async Task FinalizarMatricula(MatriculaPagamentoRealizadoIntegrationEven
{
using var scope = _serviceProvider.CreateScope();
- var _alunoRepository = scope.ServiceProvider.GetRequiredService();
+ var alunoRepository = scope.ServiceProvider.GetRequiredService();
- var matricula = await _alunoRepository.ObterMatriculaComAlunoPorId(message.MatriculaId, default)
+ var matricula = await alunoRepository.ObterMatriculaComAlunoPorId(message.MatriculaId, default)
?? throw new DomainException($"Matrícula {message.MatriculaId} não encontrada.");
matricula.Aluno.ConcluirPagamentoMatricula(matricula);
- if (await _alunoRepository.UnitOfWork.Commit() is false)
+ if (await alunoRepository.UnitOfWork.Commit() is false)
throw new DomainException($"Problemas ao ativar a matricula {message.MatriculaId}");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/RegistroAlunoIntegrationHandler.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/RegistroAlunoIntegrationHandler.cs
index a7c7702..eb70c24 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/RegistroAlunoIntegrationHandler.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Application/Services/RegistroAlunoIntegrationHandler.cs
@@ -19,6 +19,12 @@ public RegistroAlunoIntegrationHandler(IMessageBus bus, IServiceProvider service
_serviceProvider = serviceProvider;
}
+ protected override Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ SetResponder();
+ return Task.CompletedTask;
+ }
+
private void SetResponder()
{
_bus.RespondAsync(async request =>
@@ -27,12 +33,6 @@ private void SetResponder()
_bus.AdvancedBus.Connected += OnConnect!;
}
- protected override Task ExecuteAsync(CancellationToken stoppingToken)
- {
- SetResponder();
- return Task.CompletedTask;
- }
-
private void OnConnect(object s, EventArgs e)
{
SetResponder();
@@ -52,4 +52,4 @@ private async Task RegistrarCliente(UsuarioRegistradoIntegratio
return new ResponseMessage(sucesso);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContext.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContext.cs
index ff0cbc4..b787bd8 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContext.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContext.cs
@@ -16,10 +16,21 @@ public GestaoAlunoContext(DbContextOptions options, IMediato
_mediatorHandler = rebusHandler ?? throw new ArgumentNullException(nameof(rebusHandler));
}
- public DbSet Alunos { get; set; }
- public DbSet Matriculas { get; set; }
- public DbSet Certificados { get; set; }
- public DbSet ProgressoAulas { get; set; }
+ public DbSet Alunos { get; set; } = default!;
+
+ public DbSet Matriculas { get; set; } = default!;
+
+ public DbSet Certificados { get; set; } = default!;
+
+ public DbSet ProgressoAulas { get; set; } = default!;
+
+ public async Task Commit()
+ {
+ var sucesso = await base.SaveChangesAsync() > 0;
+ if (sucesso) await _mediatorHandler.PublicarEventos(this);
+
+ return sucesso;
+ }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@@ -28,19 +39,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.ApplyConfigurationsFromAssembly(typeof(GestaoAlunoContext).Assembly);
- modelBuilder.Ignore();
+ modelBuilder.Ignore();
foreach (var relationship in modelBuilder.Model.GetEntityTypes()
.SelectMany(e => e.GetForeignKeys())) relationship.DeleteBehavior = DeleteBehavior.ClientCascade;
base.OnModelCreating(modelBuilder);
}
- public async Task Commit()
- {
- var sucesso = await base.SaveChangesAsync() > 0;
- if (sucesso) await _mediatorHandler.PublicarEventos(this);
-
- return sucesso;
- }
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContextFactory.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContextFactory.cs
index 48fb841..9fdb8a4 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContextFactory.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/GestaoAlunoContextFactory.cs
@@ -1,27 +1,30 @@
+using FluentValidation.Results;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
-using FluentValidation.Results;
using PlataformaEducacao.Core.Mediator;
using PlataformaEducacao.Core.Messages;
-namespace PlataformaEducacao.GestaoAluno.Data;
-
-public sealed class GestaoAlunoContextFactory : IDesignTimeDbContextFactory
+namespace PlataformaEducacao.GestaoAluno.Data
{
- public GestaoAlunoContext CreateDbContext(string[] args)
+ public sealed class GestaoAlunoContextFactory : IDesignTimeDbContextFactory
{
- var options = new DbContextOptionsBuilder()
- .UseSqlServer("Server=localhost,1433;Database=GestaoAluno;User Id=sa;Password=Plataforma@2026;TrustServerCertificate=True")
- .Options;
+ public GestaoAlunoContext CreateDbContext(string[] args)
+ {
+ var options = new DbContextOptionsBuilder()
+ .UseSqlServer("Server=localhost,1433;Database=GestaoAluno;User Id=sa;Password=Plataforma@2026;TrustServerCertificate=True")
+ .Options;
- return new GestaoAlunoContext(options, new DesignTimeMediatorHandler());
- }
+ return new GestaoAlunoContext(options, new DesignTimeMediatorHandler());
+ }
- private sealed class DesignTimeMediatorHandler : IMediatorHandler
- {
- public Task PublishEvent(T evento) where T : Event => Task.CompletedTask;
+ private sealed class DesignTimeMediatorHandler : IMediatorHandler
+ {
+ public Task PublishEvent(T evento)
+ where T : Evento => Task.CompletedTask;
- public Task SendCommand(T comando) where T : Command =>
- Task.FromResult(new ValidationResult());
+ public Task SendCommand(T comando)
+ where T : Command =>
+ Task.FromResult(new ValidationResult());
+ }
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Mappings/AlunoMapping.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Mappings/AlunoMapping.cs
index 422ff9b..a0542ed 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Mappings/AlunoMapping.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Mappings/AlunoMapping.cs
@@ -16,7 +16,6 @@ public void Configure(EntityTypeBuilder builder)
builder.Property(a => a.Nome)
.IsRequired();
-
builder.OwnsOne(c => c.Email, tf =>
{
tf.Property(c => c.Endereco)
@@ -24,7 +23,6 @@ public void Configure(EntityTypeBuilder builder)
.HasColumnName("Email")
.HasColumnType($"varchar({Email.EnderecoMaxLength})");
});
-
}
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260209203739_Initial.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260209203739_Initial.cs
index a3e678d..beb3d7f 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260209203739_Initial.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260209203739_Initial.cs
@@ -1,10 +1,12 @@
-using Microsoft.EntityFrameworkCore.Migrations;
+using System.Diagnostics.CodeAnalysis;
+using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace PlataformaEducacao.GestaoAluno.Data.Migrations
{
///
+ [ExcludeFromCodeCoverage]
public partial class Initial : Migration
{
///
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260702222349_SqlServerBaseline.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260702222349_SqlServerBaseline.cs
index 7cd7fec..9bb1061 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260702222349_SqlServerBaseline.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/20260702222349_SqlServerBaseline.cs
@@ -1,16 +1,19 @@
+using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
-namespace PlataformaEducacao.GestaoAluno.Data.Migrations;
-
-public partial class SqlServerBaseline : Migration
+namespace PlataformaEducacao.GestaoAluno.Data.Migrations
{
- protected override void Up(MigrationBuilder migrationBuilder)
+ [ExcludeFromCodeCoverage]
+ public partial class SqlServerBaseline : Migration
{
- }
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ }
- protected override void Down(MigrationBuilder migrationBuilder)
- {
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ }
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/GestaoAlunoContextModelSnapshot.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/GestaoAlunoContextModelSnapshot.cs
index de592e4..9189c5c 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/GestaoAlunoContextModelSnapshot.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Migrations/GestaoAlunoContextModelSnapshot.cs
@@ -1,5 +1,6 @@
//
using System;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
@@ -10,6 +11,7 @@
namespace PlataformaEducacao.GestaoAluno.Data.Migrations
{
+ [ExcludeFromCodeCoverage]
[DbContext(typeof(GestaoAlunoContext))]
partial class GestaoAlunoContextModelSnapshot : ModelSnapshot
{
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Repository/AlunoRepository.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Repository/AlunoRepository.cs
index f9abaf3..fe08da2 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Repository/AlunoRepository.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Repository/AlunoRepository.cs
@@ -20,10 +20,12 @@ public async Task Inserir(Aluno aluno, CancellationToken cancellationToken)
{
await _context.Alunos.AddAsync(aluno, cancellationToken);
}
+
public Task AtualizarMatricula(Matricula matricula, CancellationToken cancellationToken)
{
return Task.FromResult(_context.Matriculas.Update(matricula));
}
+
public async Task AtualizarProgressoAula(ProgressoAula progressoAula, CancellationToken cancellationToken)
{
await _context.ProgressoAulas.AddAsync(progressoAula, cancellationToken);
@@ -33,6 +35,7 @@ public async Task GerarCertificado(Certificado certificado, CancellationToken ca
{
await _context.Certificados.AddAsync(certificado, cancellationToken);
}
+
public async Task> ListarMatriculasPendentesPagamentoPorAlunoId(Guid alunoId, CancellationToken cancellationToken)
{
return await _context.Matriculas
@@ -54,6 +57,7 @@ public async Task> ObterAlunosMatriculadosPorCursoId(Guid
m.CursoId == cursoId)
.ToListAsync(cancellationToken);
}
+
public async Task> ObterAlunosPendentesPorCursoId(Guid cursoId, CancellationToken cancellationToken)
{
return await _context.Matriculas
@@ -88,6 +92,7 @@ public async Task> ObterAlunosPendentesPorCursoId(Guid cu
.Include(m => m.ProgressoAulas)
.FirstOrDefaultAsync(m => m.Id == matriculaId, cancellationToken);
}
+
public async Task ObterMatriculaComCertificadoPorId(Guid matriculaId, CancellationToken cancellationToken)
{
return await _context.Matriculas
@@ -111,6 +116,7 @@ public async Task RealizarMatricula(Matricula matricula, CancellationToken cance
{
await _context.Matriculas.AddAsync(matricula, cancellationToken);
}
+
public async Task ObterCertificadoPorCodigoVerificacao(string codigoVerificacao, CancellationToken cancellationToken)
{
return await _context.Matriculas
@@ -120,6 +126,7 @@ public async Task RealizarMatricula(Matricula matricula, CancellationToken cance
.AsNoTracking()
.FirstOrDefaultAsync(m => m.Certificado!.CodigoVerificacao == codigoVerificacao, cancellationToken);
}
+
public async Task ObterCertificadoPorCertificadoId(Guid certificadoId, CancellationToken cancellationToken)
{
return await _context.Certificados
@@ -130,9 +137,9 @@ public async Task RealizarMatricula(Matricula matricula, CancellationToken cance
.AsNoTracking()
.FirstOrDefaultAsync(c => c.Id == certificadoId, cancellationToken);
}
+
public void Dispose()
{
-
}
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Services/CertificadoService.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Services/CertificadoService.cs
index a982998..ff2fb2f 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Services/CertificadoService.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Data/Services/CertificadoService.cs
@@ -40,7 +40,7 @@ public async Task GerarCertificado(Certificado certificado)
.Text(text =>
{
text.Span("A Escola PlataformaEducacao certifica para os devidos fins que ").FontSize(18);
- text.Span($"{certificado.Matricula.Aluno?.Nome?.ToUpper()}").Bold().FontSize(18);
+ text.Span($"{certificado.Matricula.Aluno?.Nome?.ToUpper(System.Globalization.CultureInfo.CurrentCulture)}").Bold().FontSize(18);
text.Span($" concluiu o curso {certificado.Matricula.NomeCurso}").FontSize(18);
text.Span($" na data {certificado.Matricula.HistoricoAprendizado?.DataConclusao:dd/MM/yyyy}.").FontSize(18);
});
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Aluno.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Aluno.cs
index dae17a6..c01a952 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Aluno.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Aluno.cs
@@ -6,15 +6,12 @@ namespace PlataformaEducacao.GestaoAluno.Domain
public class Aluno : Entity, IAggregateRoot
{
public string Nome { get; private set; } = null!;
+
public Email Email { get; private set; } = null!;
private readonly List _matriculas;
- public IReadOnlyCollection Matriculas => _matriculas;
- protected Aluno()
- {
- _matriculas = [];
- }
+ public IReadOnlyCollection Matriculas => _matriculas;
public Aluno(Guid alunoId, string nome, string email)
{
@@ -26,10 +23,9 @@ public Aluno(Guid alunoId, string nome, string email)
Validar();
}
- protected void Validar()
+ protected Aluno()
{
- Validacoes.ValidarSeVazio(Id, "O id do aluno é obrigatório.");
- Validacoes.ValidarSeVazio(Nome, "O nome do aluno é obrigatório.");
+ _matriculas = [];
}
public void RealizarMatricula(Matricula matricula)
@@ -65,5 +61,11 @@ public void ConcluirPagamentoMatricula(Matricula matricula)
matricula.Ativar();
}
+
+ protected void Validar()
+ {
+ Validacoes.ValidarSeVazio(Id, "O id do aluno é obrigatório.");
+ Validacoes.ValidarSeVazio(Nome, "O nome do aluno é obrigatório.");
+ }
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Certificado.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Certificado.cs
index 56d8d86..5d52c9c 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Certificado.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Certificado.cs
@@ -6,10 +6,10 @@ namespace PlataformaEducacao.GestaoAluno.Domain
public class Certificado : Entity
{
public Guid MatriculaId { get; private set; }
+
public string CodigoVerificacao { get; private set; } = null!;
- public Matricula Matricula { get; private set; } = null!;
- protected Certificado() { }
+ public Matricula Matricula { get; private set; } = null!;
public Certificado(Guid matriculaId)
{
@@ -18,9 +18,8 @@ public Certificado(Guid matriculaId)
Validar();
}
- private void GerarCodigoValidacao()
+ protected Certificado()
{
- CodigoVerificacao = Guid.NewGuid().ToString();
}
protected void Validar()
@@ -29,6 +28,11 @@ protected void Validar()
Validacoes.ValidarSeVazio(CodigoVerificacao, "O código de verificação é obrigatório.");
}
+ private void GerarCodigoValidacao()
+ {
+ CodigoVerificacao = Guid.NewGuid().ToString();
+ }
+
public static class CertificadoFactory
{
public static Certificado CriarCompleto(Matricula matricula, string codigoVerificacao)
@@ -45,4 +49,4 @@ public static Certificado CriarCompleto(Matricula matricula, string codigoVerifi
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/CursoFinalizadoEvent.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/CursoFinalizadoEvent.cs
index f4a13c7..d3f4894 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/CursoFinalizadoEvent.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/CursoFinalizadoEvent.cs
@@ -2,7 +2,7 @@
namespace PlataformaEducacao.GestaoAluno.Domain.Events
{
- public class CursoFinalizadoEvent : Event
+ public class CursoFinalizadoEvent : Evento
{
public Guid MatriculaId { get; private set; }
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/MatriculaAtivadaEvent.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/MatriculaAtivadaEvent.cs
index 19edf33..b04b425 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/MatriculaAtivadaEvent.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Events/MatriculaAtivadaEvent.cs
@@ -2,7 +2,7 @@
namespace PlataformaEducacao.GestaoAluno.Domain.Events
{
- public class MatriculaAtivadaEvent : Event
+ public class MatriculaAtivadaEvent : Evento
{
public Guid MatriculaId { get; private set; }
@@ -10,7 +10,6 @@ public MatriculaAtivadaEvent(Guid matriculaId)
{
AggregateId = matriculaId;
MatriculaId = matriculaId;
-
}
}
}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/HistoricoAprendizado.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/HistoricoAprendizado.cs
index f891428..9661107 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/HistoricoAprendizado.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/HistoricoAprendizado.cs
@@ -5,11 +5,16 @@ namespace PlataformaEducacao.GestaoAluno.Domain
public class HistoricoAprendizado
{
public int TotalAulasCurso { get; private set; }
+
public double ProgressoGeralCurso { get; private set; }
+
public SituacaoCurso SituacaoCurso { get; private set; }
+
public DateTime? DataConclusao { get; private set; }
- protected HistoricoAprendizado() { }
+ protected HistoricoAprendizado()
+ {
+ }
public static class HistoricoAprendizadoFactory
{
@@ -61,4 +66,4 @@ protected void Validar()
Validacoes.ValidarSeMenorOuIgualQue(valor: TotalAulasCurso, minimo: 0, "O número de aulas do curso deve ser maior que zero.");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Matricula.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Matricula.cs
index a986476..5789307 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Matricula.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Matricula.cs
@@ -7,22 +7,26 @@ namespace PlataformaEducacao.GestaoAluno.Domain
public class Matricula : Entity
{
public Guid CursoId { get; private set; }
+
public string NomeCurso { get; private set; } = null!;
+
public decimal Valor { get; private set; }
+
public Guid AlunoId { get; private set; }
+
public DateTime DataMatricula { get; private set; }
+
public SituacaoMatricula SituacaoMatricula { get; private set; }
+
public HistoricoAprendizado HistoricoAprendizado { get; private set; } = null!;
+
public Aluno Aluno { get; private set; } = null!;
+
public Certificado? Certificado { get; private set; }
private readonly List _progressoAulas;
- public IReadOnlyCollection ProgressoAulas => _progressoAulas;
- protected Matricula()
- {
- _progressoAulas = [];
- }
+ public IReadOnlyCollection ProgressoAulas => _progressoAulas;
public Matricula(Guid cursoId, string nomeCurso, int totalAulasCurso, decimal valor)
{
@@ -38,6 +42,11 @@ public Matricula(Guid cursoId, string nomeCurso, int totalAulasCurso, decimal va
Validar();
}
+ protected Matricula()
+ {
+ _progressoAulas = [];
+ }
+
public void AssociarAluno(Guid alunoId)
{
AlunoId = alunoId;
@@ -96,23 +105,13 @@ public void RegistrarAula(ProgressoAula progressoAula)
AtualizaProgressoCurso();
}
- private void AtualizaProgressoCurso()
- {
- var totalAulasCurso = HistoricoAprendizado.TotalAulasCurso;
- int aulasConcluidas = _progressoAulas.Count;
-
- double novoProgresso = (double)aulasConcluidas / totalAulasCurso * 100;
-
- HistoricoAprendizado = HistoricoAprendizado.HistoricoAprendizadoFactory.CriarEmAndamento(totalAulasCurso, novoProgresso);
- }
-
public void FinalizarCurso()
{
if (EstaAtiva() is false)
throw new DomainException("Antes de finalizar curso é obrigatório realizar pagamento da matrícula.");
- int aulasConcluidas = _progressoAulas.Count;
- int totalAulasCurso = HistoricoAprendizado.TotalAulasCurso;
+ var aulasConcluidas = _progressoAulas.Count;
+ var totalAulasCurso = HistoricoAprendizado.TotalAulasCurso;
if (HistoricoAprendizado.ProgressoGeralCurso < 100 || aulasConcluidas != totalAulasCurso)
throw new DomainException("Para finalizar curso é necessário assistir todas as aulas.");
@@ -120,7 +119,7 @@ public void FinalizarCurso()
if (HistoricoAprendizado.SituacaoCurso == SituacaoCurso.Concluido)
throw new DomainException("Curso já finalizado, não pode ser finalizado novamente.");
- double progresso = HistoricoAprendizado.ProgressoGeralCurso;
+ var progresso = HistoricoAprendizado.ProgressoGeralCurso;
HistoricoAprendizado = HistoricoAprendizado.HistoricoAprendizadoFactory.CriarFinalizado(totalAulasCurso, progresso);
@@ -142,6 +141,16 @@ protected void Validar()
Validacoes.ValidarSeMenorOuIgualQue(Valor, 0, "O valor do curso deve ser maior que zero.");
}
+ private void AtualizaProgressoCurso()
+ {
+ var totalAulasCurso = HistoricoAprendizado.TotalAulasCurso;
+ var aulasConcluidas = _progressoAulas.Count;
+
+ var novoProgresso = (double)aulasConcluidas / totalAulasCurso * 100;
+
+ HistoricoAprendizado = HistoricoAprendizado.HistoricoAprendizadoFactory.CriarEmAndamento(totalAulasCurso, novoProgresso);
+ }
+
public static class MatriculaFactory
{
public static Matricula CriarComPagamentoAprovado(Guid cursoId, string nomeCurso, int totalAulasCurso, decimal valor, Aluno aluno)
@@ -204,4 +213,4 @@ public static Matricula CriarComPagamentoEmProcessamento(Guid cursoId, string no
}
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/ProgressoAula.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/ProgressoAula.cs
index e48548e..2afa6e7 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/ProgressoAula.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/ProgressoAula.cs
@@ -6,11 +6,12 @@ namespace PlataformaEducacao.GestaoAluno.Domain
public class ProgressoAula : Entity
{
public Guid MatriculaId { get; private set; }
+
public Guid AulaId { get; private set; }
+
public DateTime DataConclusao { get; private set; }
- public Matricula Matricula { get; private set; } = null!;
- protected ProgressoAula() { }
+ public Matricula Matricula { get; private set; } = null!;
public ProgressoAula(Guid aulaId)
{
@@ -20,10 +21,14 @@ public ProgressoAula(Guid aulaId)
Validacoes.ValidarSeVazio(AulaId, "A aula não pode ser vazia.");
}
+ protected ProgressoAula()
+ {
+ }
+
public void AssociarMatricula(Guid matriculaId)
{
MatriculaId = matriculaId;
Validacoes.ValidarSeVazio(MatriculaId, "A matrícula não pode ser vazia.");
}
}
-}
\ No newline at end of file
+}
diff --git a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Repositories/IAlunoRepository.cs b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Repositories/IAlunoRepository.cs
index 9d8f8fa..371cf1a 100644
--- a/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Repositories/IAlunoRepository.cs
+++ b/src/services/GestaoAluno/PlataformaEducacao.GestaoAluno.Domain/Repositories/IAlunoRepository.cs
@@ -5,19 +5,33 @@ namespace PlataformaEducacao.GestaoAluno.Domain.Repositories
public interface IAlunoRepository : IRepository
{
Task Inserir(Aluno aluno, CancellationToken cancellationToken);
+
Task AtualizarMatricula(Matricula matricula, CancellationToken cancellationToken);
+
Task AtualizarProgressoAula(ProgressoAula progressoAula, CancellationToken cancellationToken);
+
Task ObterComMatriculasPorId(Guid alunoId, CancellationToken cancellationToken);
+
Task RealizarMatricula(Matricula matricula, CancellationToken cancellationToken);
+
Task ObterMatriculaComAlunoPorId(Guid matriculaId, CancellationToken cancellationToken);
+
Task ObterMatriculaComProgressoAulasPorId(Guid matriculaId, CancellationToken cancellationToken);
+
Task ObterMatriculaComCertificadoPorId(Guid matriculaId, CancellationToken cancellationToken);
+
Task> ListarMatriculasPendentesPagamentoPorAlunoId(Guid alunoId, CancellationToken cancellationToken);
+
Task> ObterAlunosMatriculadosPorCursoId(Guid cursoId, CancellationToken cancellationToken);
+
Task> ObterAlunosPendentesPorCursoId(Guid cursoId, CancellationToken cancellationToken);
+
Task> ObterMatriculasAtivasPorAlunoId(Guid alunoId, CancellationToken cancellationToken);
+
Task GerarCertificado(Certificado certificado, CancellationToken cancellationToken);
+
Task ObterCertificadoPorCodigoVerificacao(string codigoVerificacao, CancellationToken cancellationToken);
+
Task ObterCertificadoPorCertificadoId(Guid certificadoId, CancellationToken cancellationToken);
}
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/ApiConfig.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/ApiConfig.cs
index 6b3b05d..61d9fdc 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/ApiConfig.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/ApiConfig.cs
@@ -1,7 +1,7 @@
-using Microsoft.AspNetCore.HttpOverrides;
+using System.Text.Json.Serialization;
+using Microsoft.AspNetCore.HttpOverrides;
using PlataformaEducacao.WebApi.Core.Extensions;
using PlataformaEducacao.WebApi.Core.Identidade;
-using System.Text.Json.Serialization;
namespace PlataformaEducacao.GestaoConteudo.Api.Configurations
{
@@ -21,6 +21,7 @@ public static IHostBuilder ConfigureAppSettings(this IHostBuilder host)
return host;
}
+
public static IServiceCollection AddApiConfiguration(this IServiceCollection services, IConfiguration configuration)
{
services.AddControllers()
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbContextConfig.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbContextConfig.cs
index 57d35aa..9d9c5cc 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbContextConfig.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbContextConfig.cs
@@ -23,6 +23,7 @@ public static IServiceCollection AddDbContextConfig(this IServiceCollection serv
opt.EnableSensitiveDataLogging();
});
}
+
return services;
}
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbMigrationHelper.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbMigrationHelper.cs
index 8ca30b3..ab6b1a7 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbMigrationHelper.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DbMigrationHelper.cs
@@ -19,6 +19,7 @@ public static async Task EnsureSeedData(WebApplication application)
var service = application.Services.CreateScope().ServiceProvider;
await EnsureSeedData(service);
}
+
public static async Task EnsureSeedData(IServiceProvider serviceProvider)
{
using var scope = serviceProvider.GetRequiredService().CreateScope();
@@ -31,7 +32,7 @@ public static async Task EnsureSeedData(IServiceProvider serviceProvider)
await conteudoContext.Database.EnsureCreatedAsync();
await SeedTablesGestaoConteudo(conteudoContext);
}
- else if (env.EnvironmentName == "Development" || env.EnvironmentName == "Docker")
+ else if (env.EnvironmentName is "Development" or "Docker")
{
await conteudoContext.Database.MigrateAsync();
await SeedTablesGestaoConteudo(conteudoContext);
@@ -69,21 +70,23 @@ private static async Task SeedTablesGestaoConteudo(GestaoConteudoContext conteud
curso = new Curso(".NET Core", new ConteudoProgramatico("Conteudo do Curso de .NET Core", 30), 500, true);
curso.DefinirId(Guid.Parse("2194EB04-6C17-4379-8F07-C847C899466F"));
- for (int i = 1; i <= 1; i++)
+ for (var i = 1; i <= 1; i++)
{
var aula = new Aula($"Aula {i}", $"Conteudo da Aula {i}", i, $"Segue link dos materiais da aula {i}");
curso.AdicionarAula(aula);
}
+
await conteudoContext.Cursos.AddAsync(curso);
curso = new Curso("Dominios Ricos", new ConteudoProgramatico("Conteudo do Curso de Dominios Ricos", 30), 500, true);
curso.DefinirId(Guid.Parse("12E04CBC-6ACF-4582-9345-C74B12C8183C"));
- for (int i = 1; i <= 1; i++)
+ for (var i = 1; i <= 1; i++)
{
var aula = new Aula($"Aula {i}", $"Conteudo da Aula {i}", i, $"Segue link dos materiais da aula {i}");
aula.DefinirId(Guid.Parse("AB514ABA-7F82-4B3C-AB3E-3B311A516DE9"));
curso.AdicionarAula(aula);
}
+
await conteudoContext.Cursos.AddAsync(curso);
await conteudoContext.SaveChangesAsync();
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DependencyInjectionConfig.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DependencyInjectionConfig.cs
index 70d73f0..29da1d0 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DependencyInjectionConfig.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/DependencyInjectionConfig.cs
@@ -13,12 +13,10 @@ public static class DependencyInjectionConfig
{
public static IServiceCollection RegisterServices(this IServiceCollection services)
{
-
// Mediator
services.AddMediatR(
typeof(AdicionarAulaCommand).Assembly,
- typeof(CursoCommandHandler).Assembly
- );
+ typeof(CursoCommandHandler).Assembly);
// API
services.AddSingleton();
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/SwaggerConfig.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/SwaggerConfig.cs
index 29c221c..93727c3 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/SwaggerConfig.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Configurations/SwaggerConfig.cs
@@ -32,11 +32,11 @@ public static IServiceCollection AddSwaggerConfiguration(this IServiceCollection
{
Reference = new OpenApiReference
{
- Type=ReferenceType.SecurityScheme,
- Id="Bearer"
+ Type = ReferenceType.SecurityScheme,
+ Id = "Bearer"
}
},
- new string[]{}
+ Array.Empty()
}
});
});
@@ -52,7 +52,6 @@ public static IApplicationBuilder UseSwaggerConfiguration(this IApplicationBuild
o.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
});
-
return app;
}
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Controllers/CursosController.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Controllers/CursosController.cs
index b813e04..ecf0a4a 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Controllers/CursosController.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Controllers/CursosController.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Authorization;
+using System.Net;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using PlataformaEducacao.Core.Mediator;
using PlataformaEducacao.GestaoConteudo.Api.Requests;
@@ -6,7 +7,6 @@
using PlataformaEducacao.GestaoConteudo.Application.Queries;
using PlataformaEducacao.GestaoConteudo.Application.Queries.ViewModels;
using PlataformaEducacao.WebApi.Core.Controllers;
-using System.Net;
namespace PlataformaEducacao.GestaoConteudo.Api.Controllers
{
@@ -15,12 +15,15 @@ public class CursosController : MainController
{
private readonly ICursoQueries _cursoQueries;
private readonly IMediatorHandler _mediatorHandler;
- public CursosController(ICursoQueries cursoQueries,
- IMediatorHandler mediatorHandler)
+
+ public CursosController(
+ ICursoQueries cursoQueries,
+ IMediatorHandler mediatorHandler)
{
_cursoQueries = cursoQueries;
_mediatorHandler = mediatorHandler;
}
+
[AllowAnonymous]
[HttpGet("listar-cursos-disponiveis")]
public async Task>> ListarCursosDisponiveisParaMatricula(CancellationToken cancellationToken)
@@ -53,8 +56,8 @@ public async Task AdicionarCurso([FromBody] AdicionarCursoRequest
{
return CustomResponse(ModelState);
}
- var command = new AdicionarCursoCommand(request.Nome, request.DescricaoConteudo, request.CargaHoraria, request.Valor, request.Disponivel);
+ var command = new AdicionarCursoCommand(request.Nome, request.DescricaoConteudo, request.CargaHoraria, request.Valor, request.Disponivel);
return CustomResponse(await _mediatorHandler.SendCommand(command));
}
@@ -68,6 +71,7 @@ public async Task Atualizar(Guid id, [FromBody] AtualizarCursoReq
AdicionarErroProcessamento("O id informado não é o mesmo que foi passado no body");
return CustomResponse();
}
+
if (!ModelState.IsValid)
{
return CustomResponse(ModelState);
@@ -86,6 +90,7 @@ public async Task AdicionarAula([FromBody] AdicionarAulaRequest r
{
return CustomResponse(ModelState);
}
+
var command = new AdicionarAulaCommand(request.Titulo, request.Conteudo, request.Ordem, request.Material, request.CursoId);
return CustomResponse(await _mediatorHandler.SendCommand(command));
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Program.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Program.cs
index 449cb8f..d46a5f1 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Program.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Program.cs
@@ -25,4 +25,6 @@
app.Run();
-public partial class Program { }
+public partial class Program
+{
+}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarAulaRequest.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarAulaRequest.cs
index 0e1bcef..6af77ad 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarAulaRequest.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarAulaRequest.cs
@@ -6,12 +6,16 @@ public class AdicionarAulaRequest
{
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public Guid CursoId { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string Titulo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string Conteudo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public int Ordem { get; set; }
+
public string? Material { get; set; }
}
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarCursoRequest.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarCursoRequest.cs
index 9409971..4de34e8 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarCursoRequest.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AdicionarCursoRequest.cs
@@ -1,5 +1,5 @@
-using PlataformaEducacao.WebApi.Core.Extensions;
-using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations;
+using PlataformaEducacao.WebApi.Core.Extensions;
namespace PlataformaEducacao.GestaoConteudo.Api.Requests
{
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AtualizarCursoRequest.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AtualizarCursoRequest.cs
index 20b69f7..f1f6c98 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AtualizarCursoRequest.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Api/Requests/AtualizarCursoRequest.cs
@@ -6,14 +6,19 @@ public class AtualizarCursoRequest
{
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public Guid Id { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string Nome { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public string DescricaoConteudo { get; set; } = null!;
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public int CargaHoraria { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public decimal Valor { get; set; }
+
[Required(ErrorMessage = "O campo {0} é obrigatório.")]
public bool Disponivel { get; set; }
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommand.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommand.cs
index ee5e9ef..79e326d 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommand.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommand.cs
@@ -13,10 +13,15 @@ public AdicionarAulaCommand(string titulo, string conteudo, int ordem, string? m
Material = material;
CursoId = cursoId;
}
+
public Guid CursoId { get; private set; }
+
public string Titulo { get; private set; }
+
public string Conteudo { get; private set; }
+
public int Ordem { get; private set; }
+
public string? Material { get; set; }
public override bool EhValido()
@@ -25,31 +30,4 @@ public override bool EhValido()
return ValidationResult.IsValid;
}
}
-
- public class AdicionarAulaCommandValidation : AbstractValidator
- {
- public AdicionarAulaCommandValidation()
- {
- RuleFor(c => c.Titulo)
- .NotEmpty()
- .WithMessage("Título da aula é obrigatório.")
- .MaximumLength(255)
- .WithMessage("Título da aula deve ter no máximo 255 caracteres.");
-
- RuleFor(c => c.Conteudo)
- .NotEmpty()
- .WithMessage("O conteudo é obrigatório.")
- .MaximumLength(1000)
- .WithMessage("O conteudo deve ter no máximo 1000 caracteres.");
-
- RuleFor(c => c.Ordem)
- .GreaterThan(0)
- .WithMessage("A ordem da aula deve ser maior que 0.");
-
- RuleFor(c => c.CursoId)
- .NotEmpty()
- .WithMessage("Curso é obrigatório.");
-
- }
- }
}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommandValidation.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommandValidation.cs
new file mode 100644
index 0000000..73281c7
--- /dev/null
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarAulaCommandValidation.cs
@@ -0,0 +1,31 @@
+using FluentValidation;
+using PlataformaEducacao.Core.Messages;
+
+namespace PlataformaEducacao.GestaoConteudo.Application.Commands
+{
+ public class AdicionarAulaCommandValidation : AbstractValidator
+ {
+ public AdicionarAulaCommandValidation()
+ {
+ RuleFor(c => c.Titulo)
+ .NotEmpty()
+ .WithMessage("Título da aula é obrigatório.")
+ .MaximumLength(255)
+ .WithMessage("Título da aula deve ter no máximo 255 caracteres.");
+
+ RuleFor(c => c.Conteudo)
+ .NotEmpty()
+ .WithMessage("O conteudo é obrigatório.")
+ .MaximumLength(1000)
+ .WithMessage("O conteudo deve ter no máximo 1000 caracteres.");
+
+ RuleFor(c => c.Ordem)
+ .GreaterThan(0)
+ .WithMessage("A ordem da aula deve ser maior que 0.");
+
+ RuleFor(c => c.CursoId)
+ .NotEmpty()
+ .WithMessage("Curso é obrigatório.");
+ }
+ }
+}
diff --git a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarCursoCommand.cs b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarCursoCommand.cs
index 1b21921..28986fd 100644
--- a/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarCursoCommand.cs
+++ b/src/services/GestaoConteudo/PlataformaEducacao.GestaoConteudo.Application/Commands/AdicionarCursoCommand.cs
@@ -15,9 +15,13 @@ public AdicionarCursoCommand(string nome, string descricaoConteudo, int cargaHor
}
public string Nome { get; private set; }
+
public string DescricaoConteudo { get; private set; }
+
public int CargaHoraria { get; private set; }
+
public decimal Valor { get; private set; }
+
public bool Disponivel { get; private set; }
public override bool EhValido()
@@ -26,29 +30,4 @@ public override bool EhValido()
return ValidationResult.IsValid;
}
}
- public class AdicionarCursoCommandValidation : AbstractValidator