Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{csproj,props,targets,config,nuspec,xml}]
indent_size = 2

[*.{json,yml,yaml}]
indent_size = 2

[*.sln]
indent_style = tab

[*.md]
trim_trailing_whitespace = false

[*.cs]
# Sort using and Import directives with System.* appearing first
dotnet_sort_system_directives_first = true

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion

# Suggest more modern language features when available
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion

# Namespace preferences
csharp_style_namespace_declarations = file_scoped:suggestion

# var preferences
csharp_style_var_for_built_in_types = false:none
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:none

# Expression-bodied members
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion

# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion

# Expression-level preferences
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:none
dotnet_style_prefer_conditional_expression_over_return = true:none

# Code block preferences
csharp_prefer_braces = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion

# Naming conventions
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_underscore

dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

dotnet_naming_style.camel_case_underscore.required_prefix = _
dotnet_naming_style.camel_case_underscore.capitalization = camel_case
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: .NET CI

on:
push:
branches: [ main, develop ]
branches: [ master, develop ]
pull_request:
branches: [ main, develop ]
branches: [ master, develop ]

env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
Expand Down
15 changes: 0 additions & 15 deletions ClientManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientManager.Infrastructure.Messaging", "src\ClientManager.Infrastructure.Messaging\ClientManager.Infrastructure.Messaging.csproj", "{07AF7C49-BC46-4B46-8C0F-209B11E3E219}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientManager.Worker", "src\ClientManager.Worker\ClientManager.Worker.csproj", "{77C2F93F-E434-43B2-8979-0CFC0509F522}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -173,18 +171,6 @@ Global
{07AF7C49-BC46-4B46-8C0F-209B11E3E219}.Release|x64.Build.0 = Release|Any CPU
{07AF7C49-BC46-4B46-8C0F-209B11E3E219}.Release|x86.ActiveCfg = Release|Any CPU
{07AF7C49-BC46-4B46-8C0F-209B11E3E219}.Release|x86.Build.0 = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|x64.ActiveCfg = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|x64.Build.0 = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|x86.ActiveCfg = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Debug|x86.Build.0 = Debug|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|Any CPU.Build.0 = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|x64.ActiveCfg = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|x64.Build.0 = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|x86.ActiveCfg = Release|Any CPU
{77C2F93F-E434-43B2-8979-0CFC0509F522}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -195,7 +181,6 @@ Global
{98846CF7-5D38-4F51-B716-5CEC4C79C3F3} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
{A88C2EB6-8A7B-4B04-A94E-44E91429F604} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
{07AF7C49-BC46-4B46-8C0F-209B11E3E219} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{77C2F93F-E434-43B2-8979-0CFC0509F522} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {367C61BC-A677-42E5-B2AD-79754550DF13}
Expand Down
20 changes: 20 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project>

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors Condition="'$(Configuration)' == 'Release' AND !$(MSBuildProjectName.Contains('Tests'))">true</TreatWarningsAsErrors>
<EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
<AnalysisLevel>latest-recommended</AnalysisLevel>
<NoWarn>CA1848;CA1816;CA1000</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
5 changes: 0 additions & 5 deletions src/ClientManager.Api/ClientManager.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
Expand All @@ -21,6 +18,4 @@
<ProjectReference Include="..\ClientManager.Infrastructure.Messaging\ClientManager.Infrastructure.Messaging.csproj" />
</ItemGroup>


</Project>

16 changes: 16 additions & 0 deletions src/ClientManager.Application/AuthApplication.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ClientManager.Application.Mappers;
using ClientManager.Domain.Core.Interfaces.Services;
using ClientManager.Domain.Core.Responses;
using FluentValidation;

Expand All @@ -8,6 +9,7 @@ public class AuthApplication : IAuthApplication
{
private readonly IUserService _userService;
private readonly ITokenService _tokenService;
private readonly IEmailService _emailService;
private readonly IValidator<Dtos.User.CreateUserDto> _createUserValidator;
private readonly IValidator<Dtos.User.LoginDto> _loginValidator;

Expand All @@ -17,11 +19,13 @@ public class AuthApplication : IAuthApplication
public AuthApplication(
IUserService userService,
ITokenService tokenService,
IEmailService emailService,
IValidator<Dtos.User.CreateUserDto> createUserValidator,
IValidator<Dtos.User.LoginDto> loginValidator)
{
_userService = userService;
_tokenService = tokenService;
_emailService = emailService;
_createUserValidator = createUserValidator;
_loginValidator = loginValidator;
}
Expand Down Expand Up @@ -49,6 +53,18 @@ public AuthApplication(

await _userService.AddUserAsync(user).ConfigureAwait(false);

_ = Task.Run(async () =>
{
try
{
await _emailService.SendWelcomeEmailAsync(user.Email, user.Username).ConfigureAwait(false);
}
catch
{
// fire-and-forget: email failure should not block registration
}
});

var token = _tokenService.GenerateToken(user.Id, user.Username, user.Email, user.Role);
var refreshToken = _tokenService.GenerateRefreshToken();
_refreshTokens[refreshToken] = user.Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BCrypt.Net-Next" Version="4.0.3" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.1" />
Expand All @@ -23,4 +17,3 @@
</ItemGroup>

</Project>

Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ClientManager.Domain\ClientManager.Domain.csproj" />
</ItemGroup>
Expand All @@ -17,4 +11,3 @@
</ItemGroup>

</Project>

14 changes: 8 additions & 6 deletions src/ClientManager.Domain.Core/Helpers/DocumentHelper.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Globalization;

namespace ClientManager.Domain.Core.Helpers
{
public static class DocumentHelper
Expand Down Expand Up @@ -42,7 +44,7 @@ private static bool HasValidCpfDigits(string cpf)
int[] multiplier2 = { 11, 10, 9, 8, 7, 6, 5, 4, 3, 2 };

for (int i = 0; i < 9; i++)
sum += int.Parse(tempCpf[i].ToString()) * multiplier1[i];
sum += int.Parse(tempCpf[i].ToString(), CultureInfo.InvariantCulture) * multiplier1[i];

var remainder = sum % 11;
var digit1 = remainder < 2 ? 0 : 11 - remainder;
Expand All @@ -51,12 +53,12 @@ private static bool HasValidCpfDigits(string cpf)
sum = 0;

for (int i = 0; i < 10; i++)
sum += int.Parse(tempCpf[i].ToString()) * multiplier2[i];
sum += int.Parse(tempCpf[i].ToString(), CultureInfo.InvariantCulture) * multiplier2[i];

remainder = sum % 11;
var digit2 = remainder < 2 ? 0 : 11 - remainder;

return cpf.EndsWith(digit1.ToString() + digit2.ToString());
return cpf.EndsWith(digit1.ToString(CultureInfo.InvariantCulture) + digit2.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
}

private static bool HasValidCnpjDigits(string cnpj)
Expand All @@ -68,7 +70,7 @@ private static bool HasValidCnpjDigits(string cnpj)
var sum = 0;

for (int i = 0; i < 12; i++)
sum += int.Parse(tempCnpj[i].ToString()) * multiplier1[i];
sum += int.Parse(tempCnpj[i].ToString(), CultureInfo.InvariantCulture) * multiplier1[i];

var remainder = (sum % 11);
var digit1 = remainder < 2 ? 0 : 11 - remainder;
Expand All @@ -77,12 +79,12 @@ private static bool HasValidCnpjDigits(string cnpj)
sum = 0;

for (int i = 0; i < 13; i++)
sum += int.Parse(tempCnpj[i].ToString()) * multiplier2[i];
sum += int.Parse(tempCnpj[i].ToString(), CultureInfo.InvariantCulture) * multiplier2[i];

remainder = (sum % 11);
var digit2 = remainder < 2 ? 0 : 11 - remainder;

return cnpj.EndsWith(digit1.ToString() + digit2.ToString());
return cnpj.EndsWith(digit1.ToString(CultureInfo.InvariantCulture) + digit2.ToString(CultureInfo.InvariantCulture), StringComparison.Ordinal);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.0" />
</ItemGroup>
Expand All @@ -15,4 +9,3 @@
</ItemGroup>

</Project>

7 changes: 0 additions & 7 deletions src/ClientManager.Domain/ClientManager.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Model\DocumentFile.cs" />
</ItemGroup>
Expand All @@ -15,4 +9,3 @@
</ItemGroup>

</Project>

4 changes: 2 additions & 2 deletions src/ClientManager.Domain/Model/Customer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void UpdateDetails(string name, string email, string document, Address? a
Address = address;
}

private string CleanDocument(string document)
private static string CleanDocument(string document)
{
if (string.IsNullOrWhiteSpace(document)) return string.Empty;
return new string(document.Where(c => char.IsDigit(c)).ToArray());
Expand All @@ -59,7 +59,7 @@ public void EvaluateVerificationStatus(IEnumerable<Document> documents)
var docsList = documents?.ToList() ?? new List<Document>();

// Se não tem nenhum documento, volta/mantém como Pendente
if (!docsList.Any())
if (docsList.Count == 0)
{
SetPending();
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="12.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="9.0.0" />
Expand All @@ -26,4 +20,3 @@
</ItemGroup>

</Project>

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Globalization;
using System.Net;
using System.Net.Mail;
using ClientManager.Domain.Core.Interfaces.Services;
Expand All @@ -11,7 +12,7 @@ public class SmtpEmailService(IConfiguration configuration, ILogger<SmtpEmailSer
public async Task SendWelcomeEmailAsync(string email, string name, byte[]? attachment = null, string? attachmentName = null)
{
var host = configuration["Smtp:Host"];
var port = int.Parse(configuration["Smtp:Port"] ?? "587");
var port = int.Parse(configuration["Smtp:Port"] ?? "587", CultureInfo.InvariantCulture);
var username = configuration["Smtp:Username"];
var password = configuration["Smtp:Password"];
var fromEmail = configuration["Smtp:FromEmail"] ?? "no-reply@clientmanager.com";
Expand Down
Loading
Loading