Compare commits
29 Commits
main
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23a5ef9bfc | ||
|
|
e25a982b55 | ||
|
|
87fa0e67ef | ||
|
|
858e2adf2c | ||
|
|
2f82e5b98d | ||
|
|
3b2c8906eb | ||
|
|
4dc7e9f429 | ||
|
|
421c2bb27e | ||
|
|
30b99aa8a9 | ||
|
|
8b372b29a3 | ||
|
|
5d637e9d4f | ||
|
|
2d1dfb19ed | ||
|
|
296aff13fe | ||
|
|
f3d63ca0e3 | ||
|
|
abcddaba9d | ||
|
|
c1637b9e20 | ||
|
|
598081acea | ||
|
|
6d884d0d8b | ||
|
|
4d43ac70cd | ||
|
|
3b42b60757 | ||
|
|
4cea65632b | ||
|
|
a9981b6eb3 | ||
|
|
a09540f20a | ||
|
|
55cee7b0d3 | ||
|
|
dcf801beff | ||
|
|
82ebe4408b | ||
|
|
46ebccf797 | ||
|
|
614cc00290 | ||
|
|
f6595ed1df |
@ -1,20 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Blueprint.Storage" Version="0.3.0-alpha0049" />
|
||||
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" />
|
||||
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Cerberos.External\Core.Cerberos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,12 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AcceptUserConsentFormRequest : ICommand
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddCompanyToUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string CompanyId { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class AddProjectToUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string ProjectId { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveCompanyFromUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string CompanyId { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class RemoveProjectFromUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string UserId { get; set; }
|
||||
public string ProjectId { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
@Core.Cerberos.Service.API_HostAddress = http://localhost:5145
|
||||
|
||||
GET {{Core.Cerberos.Service.API_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
@ -1,99 +0,0 @@
|
||||
using Asp.Versioning.ApiExplorer;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||
using Swashbuckle.AspNetCore.SwaggerUI;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Extensions
|
||||
{
|
||||
public static class SwaggerExtensions
|
||||
{
|
||||
public static void AddSwagger(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddEndpointsApiExplorer();
|
||||
AddSwaggerGen(services, configuration);
|
||||
services.AddTransient<IConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerOptions>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures Swagger generation with OAuth2 security and XML comments.
|
||||
/// </summary>
|
||||
/// <param name="services">The <see cref="IServiceCollection"/> to add the services to.</param>
|
||||
/// <param name="configuration">The <see cref="IConfiguration"/> containing Swagger and OAuth2 configuration settings.</param>
|
||||
public static void AddSwaggerGen(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddSwaggerGen(c =>
|
||||
{
|
||||
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
|
||||
{
|
||||
Description = "JWT Authorization header using the Bearer scheme",
|
||||
Name = "Authorization",
|
||||
In = ParameterLocation.Header,
|
||||
Type = SecuritySchemeType.Http,
|
||||
Scheme = "bearer",
|
||||
BearerFormat = "JWT"
|
||||
});
|
||||
|
||||
c.AddSecurityRequirement(new OpenApiSecurityRequirement
|
||||
{
|
||||
{
|
||||
new OpenApiSecurityScheme
|
||||
{
|
||||
Reference = new OpenApiReference
|
||||
{
|
||||
Type = ReferenceType.SecurityScheme,
|
||||
Id = "Bearer"
|
||||
}
|
||||
},
|
||||
Array.Empty<string>()
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
public static void ConfigureSwagger(this WebApplication app)
|
||||
{
|
||||
//Swagger Stuff Goes Here
|
||||
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
foreach (var version in app.DescribeApiVersions().Select(version => version.GroupName))
|
||||
options.SwaggerEndpoint($"/swagger/{version}/swagger.json", version);
|
||||
|
||||
options.DisplayRequestDuration();
|
||||
options.EnableTryItOutByDefault();
|
||||
options.DocExpansion(DocExpansion.None);
|
||||
});
|
||||
|
||||
// app.MapGet("/", () => Results.Redirect("/swagger/index.html")).WithTags(string.Empty);
|
||||
}
|
||||
public static IServiceCollection AddVersioning(this IServiceCollection services)
|
||||
{
|
||||
services.AddApiVersioning(options => options.ReportApiVersions = true)
|
||||
.AddApiExplorer(options =>
|
||||
{
|
||||
options.GroupNameFormat = "'v'VVV";
|
||||
options.SubstituteApiVersionInUrl = true;
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
public class ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider) : IConfigureOptions<SwaggerGenOptions>
|
||||
{
|
||||
private readonly IApiVersionDescriptionProvider _provider = provider;
|
||||
|
||||
public void Configure(SwaggerGenOptions options)
|
||||
{
|
||||
foreach (var description in _provider.ApiVersionDescriptions)
|
||||
options.SwaggerDoc(description.GroupName, new()
|
||||
{
|
||||
Title = AppDomain.CurrentDomain.FriendlyName,
|
||||
Version = description.ApiVersion.ToString()
|
||||
});
|
||||
|
||||
|
||||
options.CustomSchemaIds(type => type.ToString().Replace("+", "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,170 +0,0 @@
|
||||
using Core.Cerberos.Adapters.Extensions;
|
||||
using Core.Cerberos.Adapters.Helpers;
|
||||
using Core.Cerberos.Application.UseCases.Modules;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Adapter;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Validator;
|
||||
using Core.Cerberos.Application.UseCases.Permissions;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Adapter;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Validator;
|
||||
using Core.Cerberos.Application.UseCases.Role;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Adapter;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Validator;
|
||||
using Core.Cerberos.Application.UseCases.Users;
|
||||
using Core.Cerberos.Application.UseCases.Users.Adapter;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Users.Validator;
|
||||
using Core.Cerberos.External.ClientConfiguration;
|
||||
using Core.Cerberos.Service.API.Extensions;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.ResponseCompression;
|
||||
using System.IO.Compression;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var authSettings = AuthHelper.GetAuthSettings(builder, "cerberos_service");
|
||||
|
||||
builder.Services.ConfigureAuthentication(builder.Configuration, authSettings);
|
||||
|
||||
builder.Host.ConfigureServices((context, services) =>
|
||||
{
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("AllowAll", policyBuilder =>
|
||||
policyBuilder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod());
|
||||
});
|
||||
services.AddMvc().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.WriteIndented = true;
|
||||
options.JsonSerializerOptions.MaxDepth = 20;
|
||||
options.JsonSerializerOptions.NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals;
|
||||
});
|
||||
services.Configure<BrotliCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.SmallestSize;
|
||||
});
|
||||
services.Configure<GzipCompressionProviderOptions>(options =>
|
||||
{
|
||||
options.Level = CompressionLevel.SmallestSize;
|
||||
});
|
||||
services.AddResponseCompression(options =>
|
||||
{
|
||||
options.EnableForHttps = true;
|
||||
options.Providers.Add<BrotliCompressionProvider>();
|
||||
options.Providers.Add<GzipCompressionProvider>();
|
||||
});
|
||||
|
||||
services.AddResponseCaching();
|
||||
services.AddControllers();
|
||||
services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwagger(builder.Configuration, "Core.Cerberos.Service.API.xml", authSettings);
|
||||
builder.Services.AddVersioning(builder.Configuration);
|
||||
services.AddLogging();
|
||||
services.AddProblemDetails();
|
||||
|
||||
//Register Stuff
|
||||
services.RegisterExternalLayer(builder.Configuration);
|
||||
|
||||
services.AddScoped<IUserPort, UserPort>();
|
||||
services.AddScoped<IComponentHandler<GetAllUsersRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<GetUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<LoginUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<LogoutUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<GetUserByEmailRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<AddCompanyToUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<RemoveCompanyFromUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<AddProjectToUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<RemoveProjectFromUserRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<ValidateUserExistenceRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<GetTokenAdapterRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<GetConsentFormPDFRequest>, UserHandler>();
|
||||
services.AddScoped<IComponentHandler<AcceptUserConsentFormRequest>, UserHandler>();
|
||||
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateUserValidator>();
|
||||
services.AddScoped<IValidator<CreateUserRequest>, CreateUserValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateUserRequest>, UserHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateUserValidator>();
|
||||
services.AddScoped<IValidator<UpdateUserRequest>, UpdateUserValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateUserRequest>, UserHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<ChangeUserStatusValidator>();
|
||||
services.AddScoped<IValidator<ChangeUserStatusRequest>, ChangeUserStatusValidator>();
|
||||
services.AddScoped<IComponentHandler<ChangeUserStatusRequest>, UserHandler>();
|
||||
|
||||
services.AddScoped<IRolePort, RolePort>();
|
||||
services.AddScoped<IComponentHandler<GetAllRolesRequest>, RoleHandler>();
|
||||
services.AddScoped<IComponentHandler<GetRoleRequest>, RoleHandler>();
|
||||
services.AddScoped<IComponentHandler<AddApplicationToRoleRequest>, RoleHandler>();
|
||||
services.AddScoped<IComponentHandler<RemoveApplicationFromRoleRequest>, RoleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateRoleValidator>();
|
||||
services.AddScoped<IValidator<CreateRoleRequest>, CreateRoleValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateRoleRequest>, RoleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateRoleValidator>();
|
||||
services.AddScoped<IValidator<UpdateRoleRequest>, UpdateRoleValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateRoleRequest>, RoleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<ChangeRoleStatusValidator>();
|
||||
services.AddScoped<IValidator<ChangeRoleStatusRequest>, ChangeRoleStatusValidator>();
|
||||
services.AddScoped<IComponentHandler<ChangeRoleStatusRequest>, RoleHandler>();
|
||||
|
||||
services.AddScoped<IPermissionPort, PermissionPort>();
|
||||
services.AddScoped<IComponentHandler<GetAllPermissionsRequest>, PermissionHandler>();
|
||||
services.AddScoped<IComponentHandler<GetPermissionRequest>, PermissionHandler>();
|
||||
services.AddScoped<IComponentHandler<GetAllPermissionsByListRequest>, PermissionHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreatePermissionValidator>();
|
||||
services.AddScoped<IValidator<CreatePermissionRequest>, CreatePermissionValidator>();
|
||||
services.AddScoped<IComponentHandler<CreatePermissionRequest>, PermissionHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdatePermissionValidator>();
|
||||
services.AddScoped<IValidator<UpdatePermissionRequest>, UpdatePermissionValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdatePermissionRequest>, PermissionHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<ChangePermissionStatusValidator>();
|
||||
services.AddScoped<IValidator<ChangePermissionStatusRequest>, ChangePermissionStatusValidator>();
|
||||
services.AddScoped<IComponentHandler<ChangePermissionStatusRequest>, PermissionHandler>();
|
||||
|
||||
services.AddScoped<IModulePort, ModulePort>();
|
||||
services.AddScoped<IComponentHandler<GetAllModulesRequest>, ModuleHandler>();
|
||||
services.AddScoped<IComponentHandler<GetModuleRequest>, ModuleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetAllModulesByListValidator>();
|
||||
services.AddScoped<IValidator<GetAllModulesByListRequest>, GetAllModulesByListValidator>();
|
||||
services.AddScoped<IComponentHandler<GetAllModulesByListRequest>, ModuleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateModuleValidator>();
|
||||
services.AddScoped<IValidator<CreateModuleRequest>, CreateModuleValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateModuleRequest>, ModuleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateModuleValidator>();
|
||||
services.AddScoped<IValidator<UpdateModuleRequest>, UpdateModuleValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateModuleRequest>, ModuleHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<ChangeModuleStatusValidator>();
|
||||
services.AddScoped<IValidator<ChangeModuleStatusRequest>, ChangeModuleStatusValidator>();
|
||||
services.AddScoped<IComponentHandler<ChangeModuleStatusRequest>, ModuleHandler>();
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
app.UseSwaggerUI(builder.Configuration, authSettings);
|
||||
app.ConfigureSwagger(builder.Configuration);
|
||||
app.UseResponseCompression();
|
||||
app.UseResponseCaching();
|
||||
app.UseHttpsRedirection();
|
||||
app.UseCors("AllowAll");
|
||||
app.UseAuthorization();
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
"Endpoints": {
|
||||
"AppConfigurationURI": "https://sandbox-hci-usc-appcg.azconfig.io"
|
||||
}
|
||||
}
|
||||
21
Core.Thalos.Application/Core.Thalos.Application.csproj
Normal file
21
Core.Thalos.Application/Core.Thalos.Application.csproj
Normal file
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MongoDB.Driver" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core.Thalos.External\Core.Thalos.External.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="UseCases\Users\Ports\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Adapter
|
||||
{
|
||||
public class ModulePort : BasePresenter, IModulePort
|
||||
{
|
||||
@ -1,16 +1,16 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class ChangeModuleStatusRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class CreateModuleRequest : Notificator, ICommand
|
||||
{
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class DeleteModuleRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetAllModulesByListRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetAllModulesRequest : ICommand
|
||||
{
|
||||
@ -1,13 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class GetModuleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,21 +1,20 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Input
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Input
|
||||
{
|
||||
public class UpdateModuleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string _Id { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
public string? Icon { get; set; }
|
||||
public string Route { get; set; } = null!;
|
||||
public int? Order { get; set; }
|
||||
public ApplicationsEnum? Application { get; set; } = null!;
|
||||
public StatusEnum Status { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.Clients.Requests;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules
|
||||
namespace Core.Thalos.Application.UseCases.Modules
|
||||
{
|
||||
public class ModuleHandler :
|
||||
IComponentHandler<ChangeModuleStatusRequest>,
|
||||
@ -15,6 +15,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
IComponentHandler<GetAllModulesByListRequest>,
|
||||
IComponentHandler<UpdateModuleRequest>,
|
||||
IComponentHandler<GetModuleRequest>,
|
||||
IComponentHandler<DeleteModuleRequest>,
|
||||
IComponentHandler<CreateModuleRequest>
|
||||
{
|
||||
private readonly IModulePort _port;
|
||||
@ -22,7 +23,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
private readonly IValidator<CreateModuleRequest> _registerModuleValidator;
|
||||
private readonly IValidator<UpdateModuleRequest> _updateModuleValidator;
|
||||
private readonly IValidator<GetAllModulesByListRequest> _modulesByListValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public ModuleHandler(
|
||||
IModulePort port,
|
||||
@ -30,13 +31,13 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
IValidator<CreateModuleRequest> registerModuleValidator,
|
||||
IValidator<UpdateModuleRequest> updateModuleValidator,
|
||||
IValidator<GetAllModulesByListRequest> modulesByListValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_changeModuleStatusValidator = changeModuleStatusValidator ?? throw new ArgumentNullException(nameof(changeModuleStatusValidator));
|
||||
_registerModuleValidator = registerModuleValidator ?? throw new ArgumentNullException(nameof(registerModuleValidator));
|
||||
_updateModuleValidator = updateModuleValidator ?? throw new ArgumentNullException(nameof(updateModuleValidator));
|
||||
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
_modulesByListValidator = modulesByListValidator ?? throw new ArgumentNullException(nameof(modulesByListValidator));
|
||||
}
|
||||
|
||||
@ -46,7 +47,29 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetModuleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetModuleByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteModuleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.DeleteModuleAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -68,7 +91,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllModulesAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllModulesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -94,7 +117,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
return;
|
||||
}
|
||||
|
||||
var _result = await _cerberosDALService.GetAllModulesByListAsync(command.Modules, cancellationToken).ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllModulesByListAsync(command.Modules, cancellationToken).ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -120,7 +143,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeStatusModuleAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeStatusModuleAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -158,7 +181,7 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
Application = command.Application,
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateModuleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateModuleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -188,19 +211,18 @@ namespace Core.Cerberos.Application.UseCases.Modules
|
||||
|
||||
var request = new ModuleAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
_Id = command._Id,
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
Application = command.Application,
|
||||
Route = command.Route,
|
||||
Order = command.Order,
|
||||
Icon = command.Icon,
|
||||
Status = command.Status
|
||||
Icon = command.Icon
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
string id = command._Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateModuleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -1,13 +1,14 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Ports
|
||||
{
|
||||
public interface IModulePort : IBasePort,
|
||||
ICommandSuccessPort<ModuleAdapter>,
|
||||
ICommandSuccessPort<List<ModuleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class ChangeModuleStatusValidator : AbstractValidator<ChangeModuleStatusRequest>
|
||||
{
|
||||
public ChangeModuleStatusValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Module ID").WithMessage("Module ID is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Module ID").WithMessage("Module ID is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class CreateModuleValidator : AbstractValidator<CreateModuleRequest>
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class GetAllModulesByListValidator : AbstractValidator<GetAllModulesByListRequest>
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Modules.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Modules.Validator
|
||||
{
|
||||
public class UpdateModuleValidator : AbstractValidator<UpdateModuleRequest>
|
||||
{
|
||||
@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Adapter
|
||||
{
|
||||
public class PermissionPort : BasePresenter, IPermissionPort
|
||||
{
|
||||
@ -1,16 +1,16 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class ChangePermissionStatusRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class CreatePermissionRequest : Notificator, ICommand
|
||||
{
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class DeletePermissionRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetAllPermissionsByListRequest : ICommand
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetAllPermissionsRequest : ICommand
|
||||
{
|
||||
@ -1,13 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class GetPermissionRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,18 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Input
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Input
|
||||
{
|
||||
public class UpdatePermissionRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string _Id { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
public AccessLevelEnum? AccessLevel { get; set; } = null!;
|
||||
public StatusEnum Status { get; set; }
|
||||
public Blueprint.Mongo.StatusEnum Status { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.Clients.Requests;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
namespace Core.Thalos.Application.UseCases.Permissions
|
||||
{
|
||||
public class PermissionHandler :
|
||||
IComponentHandler<ChangePermissionStatusRequest>,
|
||||
@ -15,26 +15,27 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
IComponentHandler<GetAllPermissionsByListRequest>,
|
||||
IComponentHandler<UpdatePermissionRequest>,
|
||||
IComponentHandler<GetPermissionRequest>,
|
||||
IComponentHandler<DeletePermissionRequest>,
|
||||
IComponentHandler<CreatePermissionRequest>
|
||||
{
|
||||
private readonly IPermissionPort _port;
|
||||
private readonly IValidator<ChangePermissionStatusRequest> _changePermissionStatusValidator;
|
||||
private readonly IValidator<CreatePermissionRequest> _registerPermissionValidator;
|
||||
private readonly IValidator<UpdatePermissionRequest> _updatePermissionValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public PermissionHandler(
|
||||
IPermissionPort port,
|
||||
IValidator<ChangePermissionStatusRequest> changePermissionStatusValidator,
|
||||
IValidator<CreatePermissionRequest> registerPermissionValidator,
|
||||
IValidator<UpdatePermissionRequest> updatePermissionValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_changePermissionStatusValidator = changePermissionStatusValidator ?? throw new ArgumentNullException(nameof(changePermissionStatusValidator));
|
||||
_registerPermissionValidator = registerPermissionValidator ?? throw new ArgumentNullException(nameof(registerPermissionValidator));
|
||||
_updatePermissionValidator = updatePermissionValidator ?? throw new ArgumentNullException(nameof(updatePermissionValidator));
|
||||
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetPermissionRequest command, CancellationToken cancellationToken = default)
|
||||
@ -43,7 +44,29 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetPermissionByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetPermissionByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(DeletePermissionRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.DeletePermissionAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -65,7 +88,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllPermissionsAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllPermissionsAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -85,7 +108,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllPermissionsByListAsync(command.Permissions, cancellationToken).ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllPermissionsByListAsync(command.Permissions, cancellationToken).ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -111,7 +134,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeStatusPermissionAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeStatusPermissionAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -146,7 +169,7 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
AccessLevel = command.AccessLevel
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreatePermissionAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreatePermissionAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -176,16 +199,15 @@ namespace Core.Cerberos.Application.UseCases.Permissions
|
||||
|
||||
var request = new PermissionAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
_Id = command._Id,
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
AccessLevel = command.AccessLevel,
|
||||
Status = command.Status
|
||||
AccessLevel = command.AccessLevel
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
string id = command._Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdatePermissionAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -1,13 +1,14 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Ports
|
||||
{
|
||||
public interface IPermissionPort : IBasePort,
|
||||
ICommandSuccessPort<PermissionAdapter>,
|
||||
ICommandSuccessPort<List<PermissionAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class ChangePermissionStatusValidator : AbstractValidator<ChangePermissionStatusRequest>
|
||||
{
|
||||
public ChangePermissionStatusValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Permission ID").WithMessage("Permission ID is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Permission ID").WithMessage("Permission ID is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class CreatePermissionValidator : AbstractValidator<CreatePermissionRequest>
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Permissions.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Permissions.Validator
|
||||
{
|
||||
public class UpdatePermissionValidator : AbstractValidator<UpdatePermissionRequest>
|
||||
{
|
||||
@ -1,9 +1,9 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Adapter
|
||||
{
|
||||
public class RolePort : BasePresenter, IRolePort
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class AddApplicationToRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,15 +1,15 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class ChangeRoleStatusRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class CreateRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class DeleteRoleRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetAllRolesRequest : ICommand
|
||||
{
|
||||
@ -1,13 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class GetRoleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class RemoveApplicationFromRoleRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,12 +1,12 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Input
|
||||
{
|
||||
public class UpdateRoleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string _Id { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
|
||||
@ -14,11 +14,11 @@ namespace Core.Cerberos.Application.UseCases.Roles.Input
|
||||
public ApplicationsEnum[]? Applications { get; set; }
|
||||
public string[] Modules { get; set; } = null!;
|
||||
public string[] Permissions { get; set; } = null!;
|
||||
public StatusEnum Status { get; set; }
|
||||
public Blueprint.Mongo.StatusEnum Status { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,13 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Ports
|
||||
{
|
||||
public interface IRolePort : IBasePort,
|
||||
ICommandSuccessPort<RoleAdapter>, ICommandSuccessPort<List<RoleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.Clients.Requests;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Role
|
||||
namespace Core.Thalos.Application.UseCases.Role
|
||||
{
|
||||
public class RoleHandler :
|
||||
IComponentHandler<ChangeRoleStatusRequest>,
|
||||
@ -15,6 +15,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
IComponentHandler<UpdateRoleRequest>,
|
||||
IComponentHandler<CreateRoleRequest>,
|
||||
IComponentHandler<GetRoleRequest>,
|
||||
IComponentHandler<DeleteRoleRequest>,
|
||||
IComponentHandler<AddApplicationToRoleRequest>,
|
||||
IComponentHandler<RemoveApplicationFromRoleRequest>
|
||||
|
||||
@ -23,20 +24,20 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
private readonly IValidator<ChangeRoleStatusRequest> _changeRoleStatusValidator;
|
||||
private readonly IValidator<CreateRoleRequest> _registerRoleValidator;
|
||||
private readonly IValidator<UpdateRoleRequest> _updateRoleValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public RoleHandler(
|
||||
IRolePort port,
|
||||
IValidator<ChangeRoleStatusRequest> changeRoleStatusValidator,
|
||||
IValidator<CreateRoleRequest> registerRoleValidator,
|
||||
IValidator<UpdateRoleRequest> updateRoleValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_changeRoleStatusValidator = changeRoleStatusValidator ?? throw new ArgumentNullException(nameof(changeRoleStatusValidator));
|
||||
_registerRoleValidator = registerRoleValidator ?? throw new ArgumentNullException(nameof(registerRoleValidator));
|
||||
_updateRoleValidator = updateRoleValidator ?? throw new ArgumentNullException(nameof(updateRoleValidator));
|
||||
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetRoleRequest command, CancellationToken cancellationToken = default)
|
||||
@ -45,7 +46,29 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetRoleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetRoleByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteRoleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.DeleteRoleAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -67,7 +90,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllRolesAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllRolesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -93,7 +116,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeRoleStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeRoleStatusAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -131,7 +154,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateRoleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateRoleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -161,18 +184,17 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
|
||||
var request = new RoleAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
_Id = command._Id,
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
Applications = command.Applications,
|
||||
Modules = command.Modules,
|
||||
Permissions = command.Permissions,
|
||||
Status = command.Status
|
||||
Permissions = command.Permissions
|
||||
};
|
||||
|
||||
string id = command.Id;
|
||||
string id = command._Id;
|
||||
|
||||
var result = await _cerberosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateRoleAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -194,7 +216,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.AddApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -216,7 +238,7 @@ namespace Core.Cerberos.Application.UseCases.Role
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.RemoveApplicationToRoleAsync(command.RoleId, command.Application, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class ChangeRoleStatusValidator : AbstractValidator<ChangeRoleStatusRequest>
|
||||
{
|
||||
public ChangeRoleStatusValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Role ID").WithMessage("Role ID is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Role ID").WithMessage("Role ID is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class CreateRoleValidator : AbstractValidator<CreateRoleRequest>
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Roles.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Roles.Validator
|
||||
{
|
||||
public class UpdateRoleValidator : AbstractValidator<UpdateRoleRequest>
|
||||
{
|
||||
@ -0,0 +1,19 @@
|
||||
using Core.Thalos.Application.UseCases.Tenants.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Adapter
|
||||
{
|
||||
public class TenantPort : BasePresenter, ITenantPort
|
||||
{
|
||||
public void Success(TenantAdapter output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
public void Success(List<TenantAdapter> output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
using Core.Blueprint.Mongo;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class ChangeTenantStatusRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class CreateTenantRequest : Notificator, ICommand
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string TaxIdentifier { get; set; } = null!;
|
||||
|
||||
public string AddressLine1 { get; set; } = null!;
|
||||
|
||||
public string? AddressLine2 { get; set; }
|
||||
|
||||
public string City { get; set; } = null!;
|
||||
|
||||
public string State { get; set; } = null!;
|
||||
|
||||
public string Country { get; set; } = null!;
|
||||
|
||||
public string PostalCode { get; set; } = null!;
|
||||
|
||||
public string ContactEmail { get; set; } = null!;
|
||||
|
||||
public string ContactPhone { get; set; } = null!;
|
||||
|
||||
public string? Website { get; set; }
|
||||
|
||||
public string? ConnectionString { get; set; }
|
||||
|
||||
public bool Isolated { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Name != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class DeleteTenantRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class GetConsentFormPDFRequest : ICommand
|
||||
public class GetAllTenantsRequest : ICommand
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class GetTenantRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Input
|
||||
{
|
||||
public class UpdateTenantRequest : Notificator, ICommand
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
public string TaxIdentifier { get; set; } = null!;
|
||||
|
||||
public string AddressLine1 { get; set; } = null!;
|
||||
|
||||
public string? AddressLine2 { get; set; }
|
||||
|
||||
public string City { get; set; } = null!;
|
||||
|
||||
public string State { get; set; } = null!;
|
||||
|
||||
public string Country { get; set; } = null!;
|
||||
|
||||
public string PostalCode { get; set; } = null!;
|
||||
|
||||
public string ContactEmail { get; set; } = null!;
|
||||
|
||||
public string ContactPhone { get; set; } = null!;
|
||||
|
||||
public string? Website { get; set; }
|
||||
|
||||
public string? ConnectionString { get; set; }
|
||||
|
||||
public bool Isolated { get; set; }
|
||||
public string _Id { get; set; } = null!;
|
||||
public string Id { get; init; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public string? CreatedBy { get; set; }
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
public string? UpdatedBy { get; set; }
|
||||
|
||||
public Blueprint.Mongo.StatusEnum Status { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Ports
|
||||
{
|
||||
public interface ITenantPort : IBasePort,
|
||||
ICommandSuccessPort<TenantAdapter>,
|
||||
ICommandSuccessPort<List<TenantAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
223
Core.Thalos.Application/UseCases/Tenants/TenantHandler.cs
Normal file
223
Core.Thalos.Application/UseCases/Tenants/TenantHandler.cs
Normal file
@ -0,0 +1,223 @@
|
||||
using Core.Thalos.Application.UseCases.Tenants.Input;
|
||||
using Core.Thalos.Application.UseCases.Tenants.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants
|
||||
{
|
||||
public class TenantHandler :
|
||||
IComponentHandler<ChangeTenantStatusRequest>,
|
||||
IComponentHandler<GetAllTenantsRequest>,
|
||||
IComponentHandler<UpdateTenantRequest>,
|
||||
IComponentHandler<GetTenantRequest>,
|
||||
IComponentHandler<DeleteTenantRequest>,
|
||||
IComponentHandler<CreateTenantRequest>
|
||||
{
|
||||
private readonly ITenantPort _port;
|
||||
private readonly IValidator<ChangeTenantStatusRequest> _changeTenantStatusValidator;
|
||||
private readonly IValidator<CreateTenantRequest> _registerTenantValidator;
|
||||
private readonly IValidator<UpdateTenantRequest> _updateTenantValidator;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public TenantHandler(
|
||||
ITenantPort port,
|
||||
IValidator<ChangeTenantStatusRequest> changeTenantStatusValidator,
|
||||
IValidator<CreateTenantRequest> registerTenantValidator,
|
||||
IValidator<UpdateTenantRequest> updateTenantValidator,
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_changeTenantStatusValidator = changeTenantStatusValidator ?? throw new ArgumentNullException(nameof(changeTenantStatusValidator));
|
||||
_registerTenantValidator = registerTenantValidator ?? throw new ArgumentNullException(nameof(registerTenantValidator));
|
||||
_updateTenantValidator = updateTenantValidator ?? throw new ArgumentNullException(nameof(updateTenantValidator));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetTenantRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.GetTenantByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteTenantRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.DeleteTenantAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetAllTenantsRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _thalosDALService.GetAllTenantsAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
_port.Success(_result.ToList());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
public async ValueTask ExecuteAsync(ChangeTenantStatusRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_changeTenantStatusValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _thalosDALService.ChangeStatusTenantAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(CreateTenantRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_registerTenantValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new TenantRequest
|
||||
{
|
||||
Name = command.Name,
|
||||
AddressLine1 = command.AddressLine1,
|
||||
AddressLine2 = command.AddressLine2,
|
||||
TaxIdentifier = command.TaxIdentifier,
|
||||
City = command.City,
|
||||
State = command.State,
|
||||
Country = command.Country,
|
||||
PostalCode = command.PostalCode,
|
||||
ContactEmail = command.ContactEmail,
|
||||
ContactPhone = command.ContactPhone,
|
||||
Website = command.Website,
|
||||
ConnectionString = command.ConnectionString,
|
||||
Isolated = command.Isolated
|
||||
};
|
||||
|
||||
var result = await _thalosDALService.CreateTenantAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(UpdateTenantRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_updateTenantValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new TenantAdapter
|
||||
{
|
||||
_Id = command._Id,
|
||||
Name = command.Name,
|
||||
AddressLine1 = command.AddressLine1,
|
||||
AddressLine2 = command.AddressLine2,
|
||||
TaxIdentifier = command.TaxIdentifier,
|
||||
City = command.City,
|
||||
State = command.State,
|
||||
Country = command.Country,
|
||||
PostalCode = command.PostalCode,
|
||||
ContactEmail = command.ContactEmail,
|
||||
ContactPhone = command.ContactPhone,
|
||||
Website = command.Website,
|
||||
ConnectionString = command.ConnectionString,
|
||||
Isolated = command.Isolated
|
||||
};
|
||||
|
||||
string id = command._Id;
|
||||
|
||||
var result = await _thalosDALService.UpdateTenantAsync(request, id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using Core.Thalos.Application.UseCases.Tenants.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Validator
|
||||
{
|
||||
public class ChangeTenantStatusValidator : AbstractValidator<ChangeTenantStatusRequest>
|
||||
{
|
||||
public ChangeTenantStatusValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Tenant ID").WithMessage("Tenant ID is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
using Core.Thalos.Application.UseCases.Tenants.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Validator
|
||||
{
|
||||
public class CreateTenantValidator : AbstractValidator<CreateTenantRequest>
|
||||
{
|
||||
public CreateTenantValidator()
|
||||
{
|
||||
RuleFor(i => i.Name)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.Name)
|
||||
.WithName("Tenant Name")
|
||||
.WithMessage("Tenant Name is obligatory.");
|
||||
|
||||
RuleFor(i => i.TaxIdentifier)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.TaxIdentifier)
|
||||
.WithName("Tax Identifier")
|
||||
.WithMessage("Tax Identifier is obligatory.");
|
||||
|
||||
RuleFor(i => i.AddressLine1)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.AddressLine1)
|
||||
.WithName("Address Line 1")
|
||||
.WithMessage("Address Line 1 is obligatory.");
|
||||
|
||||
RuleFor(i => i.City)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.City)
|
||||
.WithName("City")
|
||||
.WithMessage("City is obligatory.");
|
||||
|
||||
RuleFor(i => i.State)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.State)
|
||||
.WithName("State")
|
||||
.WithMessage("State is obligatory.");
|
||||
|
||||
RuleFor(i => i.Country)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.Country)
|
||||
.WithName("Country")
|
||||
.WithMessage("Country is obligatory.");
|
||||
|
||||
RuleFor(i => i.PostalCode)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.PostalCode)
|
||||
.WithName("Postal Code")
|
||||
.WithMessage("Postal Code is obligatory.");
|
||||
|
||||
RuleFor(i => i.ContactEmail)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.ContactEmail)
|
||||
.WithName("Contact Email")
|
||||
.WithMessage("Contact Email is obligatory.");
|
||||
|
||||
RuleFor(i => i.ContactPhone)
|
||||
.NotEmpty()
|
||||
.NotNull()
|
||||
.OverridePropertyName(x => x.ContactPhone)
|
||||
.WithName("Contact Phone")
|
||||
.WithMessage("Contact Phone is obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,66 @@
|
||||
using Core.Thalos.Application.UseCases.Tenants.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Tenants.Validator
|
||||
{
|
||||
public class UpdateTenantValidator : AbstractValidator<UpdateTenantRequest>
|
||||
{
|
||||
public UpdateTenantValidator()
|
||||
{
|
||||
RuleFor(i => i.Name)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Tenant Name")
|
||||
.WithMessage("Tenant Name is obligatory.");
|
||||
|
||||
RuleFor(i => i.TaxIdentifier)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Tax Identifier")
|
||||
.WithMessage("Tax Identifier is obligatory.");
|
||||
|
||||
RuleFor(i => i.AddressLine1)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Address Line 1")
|
||||
.WithMessage("Address Line 1 is obligatory.");
|
||||
|
||||
RuleFor(i => i.City)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("City")
|
||||
.WithMessage("City is obligatory.");
|
||||
|
||||
RuleFor(i => i.State)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("State")
|
||||
.WithMessage("State is obligatory.");
|
||||
|
||||
RuleFor(i => i.Country)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Country")
|
||||
.WithMessage("Country is obligatory.");
|
||||
|
||||
RuleFor(i => i.PostalCode)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Postal Code")
|
||||
.WithMessage("Postal Code is obligatory.");
|
||||
|
||||
RuleFor(i => i.ContactEmail)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Contact Email")
|
||||
.WithMessage("Contact Email is obligatory.");
|
||||
|
||||
RuleFor(i => i.ContactPhone)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Contact Phone")
|
||||
.WithMessage("Contact Phone is obligatory.");
|
||||
|
||||
RuleFor(i => i._Id)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Internal ID")
|
||||
.WithMessage("Internal ID is obligatory.");
|
||||
|
||||
RuleFor(i => i.Id)
|
||||
.NotEmpty().NotNull()
|
||||
.WithName("Tenant ID")
|
||||
.WithMessage("Tenant ID is obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
using Core.Blueprint.Storage.Adapters;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Adapter
|
||||
namespace Core.Thalos.Application.UseCases.Users.Adapter
|
||||
{
|
||||
public class UserPort : BasePresenter, IUserPort
|
||||
{
|
||||
@ -1,16 +1,16 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Blueprint.Mongo;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ChangeUserStatusRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public StatusEnum Status { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class CreateUserRequest : Notificator, ICommand
|
||||
{
|
||||
@ -9,8 +9,7 @@ namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
public string MiddleName { get; set; } = null!;
|
||||
public string LastName { get; set; } = null!;
|
||||
public string RoleId { get; set; } = null!;
|
||||
public string[] Companies { get; set; } = null!;
|
||||
public string[]? Projects { get; set; }
|
||||
public string TenantId { get; set; } = null!;
|
||||
public bool SendInvitation { get; set; }
|
||||
|
||||
public bool Validate()
|
||||
@ -0,0 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class DeleteUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetAllUsersRequest : ICommand
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetTokenAdapterRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserByEmailRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,13 +1,13 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class GetUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string _Id { get; set; }
|
||||
public bool Validate()
|
||||
{
|
||||
return Id != null;
|
||||
return _Id != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class LoginUserRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class LogoutUserRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,17 +1,16 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class UpdateUserRequest : Notificator, ICommand
|
||||
{
|
||||
public string Id { get; set; } = null!;
|
||||
public string _Id { get; set; } = null!;
|
||||
public string Email { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string? MiddleName { get; set; }
|
||||
public string LastName { get; set; } = null!;
|
||||
public string RoleId { get; set; } = null!;
|
||||
public string[] Companies { get; set; } = null!;
|
||||
public string[]? Projects { get; set; }
|
||||
public string TenantId { get; set; } = null!;
|
||||
public bool Validate()
|
||||
{
|
||||
return Email != null;
|
||||
@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Input
|
||||
namespace Core.Thalos.Application.UseCases.Users.Input
|
||||
{
|
||||
public class ValidateUserExistenceRequest : Notificator, ICommand
|
||||
{
|
||||
@ -1,8 +1,8 @@
|
||||
using Core.Blueprint.Storage.Adapters;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Ports
|
||||
namespace Core.Thalos.Application.UseCases.Users.Ports
|
||||
{
|
||||
public interface IUserPort : IBasePort,
|
||||
ICommandSuccessPort<UserAdapter>,
|
||||
@ -11,7 +11,8 @@ namespace Core.Cerberos.Application.UseCases.Users.Ports
|
||||
ICommandSuccessPort<TokenAdapter>,
|
||||
ICommandSuccessPort<BlobDownloadUriAdapter>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,49 +1,44 @@
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.Clients.Requests;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
namespace Core.Cerberos.Application.UseCases.Users
|
||||
namespace Core.Thalos.Application.UseCases.Users
|
||||
{
|
||||
public class UserHandler :
|
||||
IComponentHandler<ChangeUserStatusRequest>,
|
||||
IComponentHandler<GetAllUsersRequest>,
|
||||
IComponentHandler<UpdateUserRequest>,
|
||||
IComponentHandler<DeleteUserRequest>,
|
||||
IComponentHandler<GetUserRequest>,
|
||||
IComponentHandler<GetUserByEmailRequest>,
|
||||
IComponentHandler<CreateUserRequest>,
|
||||
IComponentHandler<AddProjectToUserRequest>,
|
||||
IComponentHandler<RemoveProjectFromUserRequest>,
|
||||
IComponentHandler<AddCompanyToUserRequest>,
|
||||
IComponentHandler<RemoveCompanyFromUserRequest>,
|
||||
IComponentHandler<LoginUserRequest>,
|
||||
IComponentHandler<LogoutUserRequest>,
|
||||
IComponentHandler<ValidateUserExistenceRequest>,
|
||||
IComponentHandler<GetTokenAdapterRequest>,
|
||||
IComponentHandler<GetConsentFormPDFRequest>,
|
||||
IComponentHandler<AcceptUserConsentFormRequest>
|
||||
IComponentHandler<GetTokenAdapterRequest>
|
||||
{
|
||||
private readonly IUserPort _port;
|
||||
private readonly IValidator<ChangeUserStatusRequest> _changeUserStatusValidator;
|
||||
private readonly IValidator<CreateUserRequest> _registerUserValidator;
|
||||
private readonly IValidator<UpdateUserRequest> _updateUserValidator;
|
||||
private readonly ICerberosServiceClient _cerberosDALService;
|
||||
private readonly IThalosServiceClient _thalosDALService;
|
||||
|
||||
public UserHandler(
|
||||
IUserPort port,
|
||||
IValidator<ChangeUserStatusRequest> changeUserStatusValidator,
|
||||
IValidator<CreateUserRequest> registerUserValidator,
|
||||
IValidator<UpdateUserRequest> updateUserValidator,
|
||||
ICerberosServiceClient cerberosDALService)
|
||||
IThalosServiceClient thalosDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_changeUserStatusValidator = changeUserStatusValidator ?? throw new ArgumentNullException(nameof(changeUserStatusValidator));
|
||||
_registerUserValidator = registerUserValidator ?? throw new ArgumentNullException(nameof(registerUserValidator));
|
||||
_updateUserValidator = updateUserValidator ?? throw new ArgumentNullException(nameof(updateUserValidator));
|
||||
_cerberosDALService = cerberosDALService ?? throw new ArgumentNullException(nameof(cerberosDALService));
|
||||
_thalosDALService = thalosDALService ?? throw new ArgumentNullException(nameof(thalosDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetUserRequest command, CancellationToken cancellationToken = default)
|
||||
@ -52,7 +47,29 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetUserByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetUserByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteUserRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _thalosDALService.DeleteUserAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -74,7 +91,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetUserByEmailAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetUserByEmailAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -96,7 +113,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.ValidateUserExistence(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ValidateUserExistence(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -118,7 +135,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetAllUsersAsync().ConfigureAwait(false);
|
||||
var _result = await _thalosDALService.GetAllUsersAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -144,7 +161,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _cerberosDALService.ChangeUserStatusAsync(command.Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.ChangeUserStatusAsync(command._Id, command.Status, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -179,11 +196,10 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
MiddleName = command.MiddleName,
|
||||
LastName = command.LastName,
|
||||
RoleId = command.RoleId,
|
||||
Companies = command.Companies,
|
||||
Projects = command.Projects,
|
||||
TenantId = command.TenantId,
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.CreateUserAsync(request, command.SendInvitation, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -213,17 +229,16 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
|
||||
var request = new UserAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
_Id = command._Id,
|
||||
Email = command.Email,
|
||||
Name = command.Name,
|
||||
MiddleName = command.MiddleName,
|
||||
LastName = command.LastName,
|
||||
RoleId = command.RoleId,
|
||||
Companies = command.Companies,
|
||||
Projects = command.Projects
|
||||
TenantId = command.TenantId
|
||||
};
|
||||
|
||||
var result = await _cerberosDALService.UpdateUserAsync(request, request.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.UpdateUserAsync(request, request._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -245,7 +260,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.LoginUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.LoginUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -267,95 +282,7 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.LogoutUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(AddCompanyToUserRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(RemoveCompanyFromUserRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveCompanyToUserAsync(command.UserId, command.CompanyId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(AddProjectToUserRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AddProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(RemoveProjectFromUserRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.RemoveProjectToUserAsync(command.UserId, command.ProjectId, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.LogoutUserAsync(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@ -377,51 +304,9 @@ namespace Core.Cerberos.Application.UseCases.Users
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.GetTokenAdapter(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _thalosDALService.GetTokenAdapter(command.Email, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
_port.Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetConsentFormPDFRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _cerberosDALService.GetConsentFormPDFAsync(cancellationToken).ConfigureAwait(false);
|
||||
if (_result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
return;
|
||||
}
|
||||
_port.Success(_result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ApiResponseHelper.EvaluatePort(ex, _port);
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(AcceptUserConsentFormRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _cerberosDALService.AcceptUserConsentFormAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@ -1,13 +1,13 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class ChangeUserStatusValidator : AbstractValidator<ChangeUserStatusRequest>
|
||||
{
|
||||
public ChangeUserStatusValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("User ID").WithMessage("User ID is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("User ID").WithMessage("User ID is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().NotNull().OverridePropertyName(x => x.Status).WithName("Status").WithMessage("Status is Obligatory.");
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class CreateUserValidator : AbstractValidator<CreateUserRequest>
|
||||
{
|
||||
@ -10,8 +10,7 @@ namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
|
||||
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
|
||||
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
|
||||
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
|
||||
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("RoleId").WithMessage("RoleId is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,17 +1,16 @@
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Users.Validator
|
||||
namespace Core.Thalos.Application.UseCases.Users.Validator
|
||||
{
|
||||
public class UpdateUserValidator : AbstractValidator<UpdateUserRequest>
|
||||
{
|
||||
public UpdateUserValidator()
|
||||
{
|
||||
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("Email is Obligatory.");
|
||||
RuleFor(i => i.Email).NotEmpty().NotNull().OverridePropertyName(x => x.Email).WithName("User Email").WithMessage("User Email is Obligatory.");
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("User Name").WithMessage("User Name is Obligatory.");
|
||||
RuleFor(i => i.LastName).NotEmpty().NotNull().OverridePropertyName(x => x.LastName).WithName("User LastName").WithMessage("User LastName is Obligatory.");
|
||||
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("Role Id").WithMessage("Role Id is Obligatory.");
|
||||
RuleFor(i => i.Companies).NotEmpty().NotNull().OverridePropertyName(x => x.Companies).WithName("Companies").WithMessage("Companies is Obligatory.");
|
||||
RuleFor(i => i.RoleId).NotEmpty().NotNull().OverridePropertyName(x => x.RoleId).WithName("RoleId").WithMessage("RoleId is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.External.Clients;
|
||||
using Core.Cerberos.External.GatewayConfigurations;
|
||||
using Core.Cerberos.External.Helpers.Token;
|
||||
using Core.Thalos.External.Clients;
|
||||
using Core.Thalos.External.GatewayConfigurations;
|
||||
using Core.Thalos.External.Helpers.Token;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
@ -8,7 +8,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.External.ClientConfiguration
|
||||
namespace Core.Thalos.External.ClientConfiguration
|
||||
{
|
||||
public static class RegisterClientConfiguration
|
||||
{
|
||||
@ -37,18 +37,18 @@ namespace Core.Cerberos.External.ClientConfiguration
|
||||
return handler;
|
||||
});
|
||||
|
||||
var cerberosServiceApiUrl = GatewaySettingsConfigurations.GetCerberosServiceAPIEndpoint().Endpoint.Url;
|
||||
var thalosServiceApiUrl = GatewaySettingsConfigurations.GetThalosServiceAPIEndpoint().Endpoint.Url;
|
||||
|
||||
// Register ICerberosServiceClient with the manually created HttpClient
|
||||
services.AddScoped<ICerberosServiceClient>(provider =>
|
||||
// Register IThalosServiceClient with the manually created HttpClient
|
||||
services.AddScoped<IThalosServiceClient>(provider =>
|
||||
{
|
||||
var handler = provider.GetRequiredService<AuthenticatedHttpClientHandler>();
|
||||
var httpClient = new HttpClient(handler)
|
||||
{
|
||||
BaseAddress = new Uri(cerberosServiceApiUrl),
|
||||
BaseAddress = new Uri(thalosServiceApiUrl),
|
||||
Timeout = TimeSpan.FromMinutes(1)
|
||||
};
|
||||
return RestService.For<ICerberosServiceClient>(httpClient);
|
||||
return RestService.For<IThalosServiceClient>(httpClient);
|
||||
});
|
||||
|
||||
services.AddScoped<IAuthenticationService, AuthenticationService>();
|
||||
@ -1,20 +1,17 @@
|
||||
using Core.Blueprint.Storage.Adapters;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Cerberos.External.Clients.Requests;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Core.Thalos.External.Clients.Requests;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Refit;
|
||||
|
||||
namespace Core.Cerberos.External.Clients
|
||||
namespace Core.Thalos.External.Clients
|
||||
{
|
||||
public interface ICerberosServiceClient
|
||||
public interface IThalosServiceClient
|
||||
{
|
||||
[Get("/v1/User")]
|
||||
Task<IEnumerable<UserAdapter>> GetAllUsersAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/User/" + Routes.Id)]
|
||||
Task<UserAdapter> GetUserByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<UserAdapter> GetUserByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/User/" + Routes.Email)]
|
||||
Task<UserAdapter> GetUserByEmailAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||
@ -26,7 +23,10 @@ namespace Core.Cerberos.External.Clients
|
||||
Task<UserAdapter> CreateUserAsync([FromBody] UserRequest newUser, [FromRoute] bool sendInvitation, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/User/" + Routes.Id)]
|
||||
Task<UserAdapter> UpdateUserAsync([FromBody] UserAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<UserAdapter> UpdateUserAsync([FromBody] UserAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/User/" + Routes.Id)]
|
||||
Task<UserAdapter> DeleteUserAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/User/" + Routes.LogIn)]
|
||||
Task<UserAdapter> LoginUserAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||
@ -35,43 +35,28 @@ namespace Core.Cerberos.External.Clients
|
||||
Task<UserAdapter> LogoutUserAsync([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/User/" + Routes.ChangeStatus)]
|
||||
Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string id, StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
Task<UserAdapter> ChangeUserStatusAsync([FromRoute] string _id, Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/User/{email}/GetTokenAdapter")]
|
||||
Task<TokenAdapter> GetTokenAdapter([FromRoute] string email, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/User/" + Routes.AddCompany)]
|
||||
Task<UserAdapter> AddCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/User/" + Routes.RemoveCompany)]
|
||||
Task<UserAdapter> RemoveCompanyToUserAsync([FromRoute] string userId, [FromRoute] string companyId, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/User/" + Routes.AddProject)]
|
||||
Task<UserAdapter> AddProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/User/" + Routes.RemoveProject)]
|
||||
Task<UserAdapter> RemoveProjectToUserAsync([FromRoute] string userId, [FromRoute] string projectId, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/User/GetConsentFormPDF")]
|
||||
Task<BlobDownloadUriAdapter> GetConsentFormPDFAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/User/AcceptUserConsentForm")]
|
||||
Task<UserAdapter> AcceptUserConsentFormAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Role")]
|
||||
Task<IEnumerable<RoleAdapter>> GetAllRolesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Role/" + Routes.Id)]
|
||||
Task<RoleAdapter> GetRoleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<RoleAdapter> GetRoleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/Role")]
|
||||
Task<RoleAdapter> CreateRoleAsync([FromBody] RoleRequest newRole, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/Role/" + Routes.Id)]
|
||||
Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<RoleAdapter> UpdateRoleAsync([FromBody] RoleAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/Role/" + Routes.Id)]
|
||||
Task<RoleAdapter> DeleteRoleAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/Role/" + Routes.ChangeStatus)]
|
||||
Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
Task<RoleAdapter> ChangeRoleStatusAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/Role/" + Routes.AddApplication)]
|
||||
Task<RoleAdapter> AddApplicationToRoleAsync([FromRoute] string RoleId, [FromRoute] ApplicationsEnum application, CancellationToken cancellationToken = default);
|
||||
@ -86,16 +71,19 @@ namespace Core.Cerberos.External.Clients
|
||||
Task<IEnumerable<PermissionAdapter>> GetAllPermissionsByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Permission/" + Routes.Id)]
|
||||
Task<PermissionAdapter> GetPermissionByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<PermissionAdapter> GetPermissionByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/Permission")]
|
||||
Task<PermissionAdapter> CreatePermissionAsync([FromBody] PermissionRequest newPermission, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/Permission/" + Routes.Id)]
|
||||
Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<PermissionAdapter> UpdatePermissionAsync([FromBody] PermissionAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/Permission/" + Routes.Id)]
|
||||
Task<PermissionAdapter> DeletePermissionAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/Permission/" + Routes.ChangeStatus)]
|
||||
Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
Task<PermissionAdapter> ChangeStatusPermissionAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Module")]
|
||||
Task<IEnumerable<ModuleAdapter>> GetAllModulesAsync(CancellationToken cancellationToken = default);
|
||||
@ -104,15 +92,36 @@ namespace Core.Cerberos.External.Clients
|
||||
Task<IEnumerable<ModuleAdapter>> GetAllModulesByListAsync([FromBody] string[] request, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Module/" + Routes.Id)]
|
||||
Task<ModuleAdapter> GetModuleByIdAsync([FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<ModuleAdapter> GetModuleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/Module")]
|
||||
Task<ModuleAdapter> CreateModuleAsync([FromBody] ModuleRequest newModule, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/Module/" + Routes.Id)]
|
||||
Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string id, CancellationToken cancellationToken = default);
|
||||
Task<ModuleAdapter> UpdateModuleAsync([FromBody] ModuleAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/Module/" + Routes.Id)]
|
||||
Task<ModuleAdapter> DeleteModuleAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/Module/" + Routes.ChangeStatus)]
|
||||
Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string id, [FromRoute] StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
Task<ModuleAdapter> ChangeStatusModuleAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Tenant")]
|
||||
Task<IEnumerable<TenantAdapter>> GetAllTenantsAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/Tenant/" + Routes.Id)]
|
||||
Task<TenantAdapter> GetTenantByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/Tenant")]
|
||||
Task<TenantAdapter> CreateTenantAsync([FromBody] TenantRequest newTenant, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/Tenant/" + Routes.Id)]
|
||||
Task<TenantAdapter> UpdateTenantAsync([FromBody] TenantAdapter entity, [FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Patch("/v1/Tenant/" + Routes.ChangeStatus)]
|
||||
Task<TenantAdapter> ChangeStatusTenantAsync([FromRoute] string _id, [FromRoute] Blueprint.Mongo.StatusEnum newStatus, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/Tenant/" + Routes.Id)]
|
||||
Task<TenantAdapter> DeleteTenantAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class ModuleRequest
|
||||
{
|
||||
@ -1,6 +1,6 @@
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class PermissionRequest
|
||||
{
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Cerberos.Adapters.Common.Enums;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class RoleRequest
|
||||
{
|
||||
53
Core.Thalos.External/Clients/Requests/TenantRequest.cs
Normal file
53
Core.Thalos.External/Clients/Requests/TenantRequest.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using Core.Blueprint.Mongo;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace Core.Thalos.BuildingBlocks
|
||||
{
|
||||
[CollectionAttributeName("Tenants")]
|
||||
public class TenantRequest : Document
|
||||
{
|
||||
[BsonElement("name")]
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
[BsonElement("taxIdentifier")]
|
||||
public string TaxIdentifier { get; set; } = null!;
|
||||
|
||||
[BsonElement("addressLine1")]
|
||||
public string AddressLine1 { get; set; } = null!;
|
||||
|
||||
[BsonElement("addressLine2")]
|
||||
[BsonIgnoreIfNull]
|
||||
public string? AddressLine2 { get; set; }
|
||||
|
||||
[BsonElement("city")]
|
||||
public string City { get; set; } = null!;
|
||||
|
||||
[BsonElement("state")]
|
||||
public string State { get; set; } = null!;
|
||||
|
||||
[BsonElement("country")]
|
||||
public string Country { get; set; } = null!;
|
||||
|
||||
[BsonElement("postalCode")]
|
||||
public string PostalCode { get; set; } = null!;
|
||||
|
||||
[BsonElement("contactEmail")]
|
||||
public string ContactEmail { get; set; } = null!;
|
||||
|
||||
[BsonElement("contactPhone")]
|
||||
public string ContactPhone { get; set; } = null!;
|
||||
|
||||
[BsonElement("website")]
|
||||
[BsonIgnoreIfNull]
|
||||
public string? Website { get; set; }
|
||||
|
||||
[BsonElement("connectionString")]
|
||||
[BsonIgnoreIfNull]
|
||||
public string? ConnectionString { get; set; }
|
||||
|
||||
[BsonElement("isolated")]
|
||||
public bool Isolated { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
namespace Core.Cerberos.External.Clients.Requests
|
||||
namespace Core.Thalos.External.Clients.Requests
|
||||
{
|
||||
public class UserRequest
|
||||
{
|
||||
@ -7,7 +7,6 @@
|
||||
public string? MiddleName { get; set; }
|
||||
public string LastName { get; set; } = null!;
|
||||
public string RoleId { get; set; } = null!;
|
||||
public string[] Companies { get; set; } = null!;
|
||||
public string[]? Projects { get; set; }
|
||||
public string TenantId { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@ -7,9 +7,9 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Core.Blueprint.Storage" Version="0.3.0-alpha0049" />
|
||||
<PackageReference Include="Core.Cerberos.Adapters" Version="0.3.0-alpha0042" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0001" />
|
||||
<PackageReference Include="BuildingBlocks.Library" Version="1.0.1" />
|
||||
<PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" />
|
||||
<PackageReference Include="Core.Thalos.BuildingBlocks" Version="1.1.9" />
|
||||
<PackageReference Include="Refit" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
using Core.Blueprint.External;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public record GatewayConfiguration
|
||||
{
|
||||
public GatewayConfiguration()
|
||||
{
|
||||
CerberosService = new CerberosServiceAPI();
|
||||
ThalosService = new ThalosServiceAPI();
|
||||
}
|
||||
|
||||
public CerberosServiceAPI CerberosService { get; set; }
|
||||
public ThalosServiceAPI ThalosService { get; set; }
|
||||
}
|
||||
public record CerberosServiceAPI
|
||||
public record ThalosServiceAPI
|
||||
{
|
||||
public string Channel { get; set; }
|
||||
public BaseEndpoint Endpoint { get; set; }
|
||||
@ -1,7 +1,7 @@
|
||||
using Core.Blueprint.External;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace Core.Cerberos.External.GatewayConfigurations
|
||||
namespace Core.Thalos.External.GatewayConfigurations
|
||||
{
|
||||
public class GatewaySettingsConfigurations
|
||||
{
|
||||
@ -11,13 +11,13 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
public GatewaySettingsConfigurations(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
this.SetCerberosServiceAPIEndpoint();
|
||||
this.SetThalosServiceAPIEndpoint();
|
||||
}
|
||||
public static CerberosServiceAPI GetCerberosServiceAPIEndpoint()
|
||||
public static ThalosServiceAPI GetThalosServiceAPIEndpoint()
|
||||
{
|
||||
return GatewayConfigurations.CerberosService;
|
||||
return GatewayConfigurations.ThalosService;
|
||||
}
|
||||
private GatewayConfiguration SetCerberosServiceAPIEndpoint()
|
||||
private GatewayConfiguration SetThalosServiceAPIEndpoint()
|
||||
{
|
||||
IConfigurationSection source;
|
||||
var environment = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? string.Empty;
|
||||
@ -27,18 +27,18 @@ namespace Core.Cerberos.External.GatewayConfigurations
|
||||
else
|
||||
source = _configuration.GetSection("Gateways");
|
||||
|
||||
var endpoint = source["CerberosDAL"] ?? string.Empty;
|
||||
var endpoint = source["ThalosDAL"] ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Cerberos DAL endpoint is empty or null");
|
||||
if (string.IsNullOrEmpty(endpoint)) throw new Exception("Thalos DAL endpoint is empty or null");
|
||||
|
||||
GatewayConfigurations.CerberosService = new CerberosServiceAPI()
|
||||
GatewayConfigurations.ThalosService = new ThalosServiceAPI()
|
||||
{
|
||||
Endpoint = new BaseEndpoint()
|
||||
{
|
||||
Uri = new Uri(endpoint),
|
||||
Url = endpoint,
|
||||
Token = string.Empty,
|
||||
APIName = "Cerberos Service"
|
||||
APIName = "Thalos Service"
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="AuthenticatedHttpClientHandler.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to inject the token in all requests.
|
||||
@ -1,12 +1,12 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="HttpContextTokenProvider.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Class to return the access token to controllers.
|
||||
@ -1,10 +1,10 @@
|
||||
// ***********************************************************************
|
||||
// <copyright file="ITokenProvider.cs">
|
||||
// Heath
|
||||
// AgileWebs
|
||||
// </copyright>
|
||||
// ***********************************************************************
|
||||
|
||||
namespace Core.Cerberos.External.Helpers.Token
|
||||
namespace Core.Thalos.External.Helpers.Token
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for token provider.
|
||||
@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.10.34928.147
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.Service.API", "Core.Cerberos.Service.API\Core.Cerberos.Service.API.csproj", "{00F5B578-77EE-44A9-A611-5D753FDF158D}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.Service.API", "Core.Thalos.Service.API\Core.Thalos.Service.API.csproj", "{00F5B578-77EE-44A9-A611-5D753FDF158D}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{F33D7786-EFE5-4618-9D47-C0272227C095}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{685F19C0-CE60-4BFB-9EDB-6834D01A6161}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Cerberos.External", "Core.Cerberos.External\Core.Cerberos.External.csproj", "{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core.Thalos.External", "Core.Thalos.External\Core.Thalos.External.csproj", "{52EB3BBE-DACB-4EE5-8FFA-B8DBE34BA137}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Cerberos.Application", "Core.Cerberos.Application\Core.Cerberos.Application.csproj", "{F1980B4D-35C3-4495-84CF-09E1D3822CDA}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core.Thalos.Application", "Core.Thalos.Application\Core.Thalos.Application.csproj", "{F1980B4D-35C3-4495-84CF-09E1D3822CDA}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -1,14 +1,12 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Input;
|
||||
using Core.Cerberos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.Application.UseCases.Modules.Input;
|
||||
using Core.Thalos.Application.UseCases.Modules.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="ModuleController"/>.
|
||||
@ -17,6 +15,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class ModuleController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<GetModuleRequest> getModuleHandler;
|
||||
@ -24,6 +23,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
private readonly IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler;
|
||||
private readonly IComponentHandler<CreateModuleRequest> createModuleHandler;
|
||||
private readonly IComponentHandler<UpdateModuleRequest> updateModuleHandler;
|
||||
private readonly IComponentHandler<DeleteModuleRequest> deleteModuleHandler;
|
||||
private readonly IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler;
|
||||
private readonly IModulePort port;
|
||||
|
||||
@ -36,12 +36,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
IComponentHandler<GetAllModulesByListRequest> getAllModulesByListHandler,
|
||||
IComponentHandler<CreateModuleRequest> createModuleHandler,
|
||||
IComponentHandler<UpdateModuleRequest> updateModuleHandler,
|
||||
IComponentHandler<DeleteModuleRequest> deleteModuleHandler,
|
||||
IComponentHandler<ChangeModuleStatusRequest> changeModuleStatusHandler,
|
||||
IModulePort port
|
||||
)
|
||||
{
|
||||
this.createModuleHandler = createModuleHandler;
|
||||
this.updateModuleHandler = updateModuleHandler;
|
||||
this.deleteModuleHandler = deleteModuleHandler;
|
||||
this.changeModuleStatusHandler = changeModuleStatusHandler;
|
||||
this.getAllModulesHandler = getAllModulesHandler;
|
||||
this.getModuleHandler = getModuleHandler;
|
||||
@ -60,7 +62,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@ -91,7 +92,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllModulesByListAsync([FromBody] GetAllModulesByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@ -107,7 +107,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the module by identifier.
|
||||
/// Gets the module by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -118,14 +118,13 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Read")]
|
||||
public async Task<IActionResult> GetModuleById([FromBody] GetModuleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (request.Id == null || !request.Id.Any())
|
||||
if (request._Id == null || !request._Id.Any())
|
||||
{
|
||||
return BadRequest("Invalid Module Id");
|
||||
return BadRequest("Invalid Module _Id");
|
||||
}
|
||||
|
||||
await getModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
@ -144,7 +143,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> CreateModuleAsync([FromBody] CreateModuleRequest newModule, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -154,7 +152,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full module by identifier.
|
||||
/// Updates a full module by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -164,7 +162,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> UpdateModuleAsync([FromBody] UpdateModuleRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -173,6 +170,25 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full module by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> DeleteModuleAsync([FromBody] DeleteModuleRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await deleteModuleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the status of the module.
|
||||
/// </summary>
|
||||
@ -185,12 +201,11 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("ModuleManagement.Write")]
|
||||
public async Task<IActionResult> ChangeModuleStatusAsync([FromBody] ChangeModuleStatusRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid module identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid module mongo identifier"); }
|
||||
|
||||
await changeModuleStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -1,14 +1,12 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Input;
|
||||
using Core.Cerberos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Input;
|
||||
using Core.Thalos.Application.UseCases.Permissions.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="PermissionController"/>.
|
||||
@ -17,6 +15,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class PermissionController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<GetPermissionRequest> getPermissionHandler;
|
||||
@ -24,6 +23,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
private readonly IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler;
|
||||
private readonly IComponentHandler<CreatePermissionRequest> createPermissionHandler;
|
||||
private readonly IComponentHandler<UpdatePermissionRequest> updatePermissionHandler;
|
||||
private readonly IComponentHandler<DeletePermissionRequest> deletePermissionHandler;
|
||||
private readonly IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler;
|
||||
private readonly IPermissionPort port;
|
||||
|
||||
@ -36,12 +36,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
IComponentHandler<GetAllPermissionsByListRequest> getAllPermissionsByListHandler,
|
||||
IComponentHandler<CreatePermissionRequest> createPermissionHandler,
|
||||
IComponentHandler<UpdatePermissionRequest> updatePermissionHandler,
|
||||
IComponentHandler<DeletePermissionRequest> deletePermissionHandler,
|
||||
IComponentHandler<ChangePermissionStatusRequest> changePermissionStatusHandler,
|
||||
IPermissionPort port
|
||||
)
|
||||
{
|
||||
this.createPermissionHandler = createPermissionHandler;
|
||||
this.updatePermissionHandler = updatePermissionHandler;
|
||||
this.deletePermissionHandler = deletePermissionHandler;
|
||||
this.changePermissionStatusHandler = changePermissionStatusHandler;
|
||||
this.getAllPermissionsHandler = getAllPermissionsHandler;
|
||||
this.getPermissionHandler = getPermissionHandler;
|
||||
@ -60,7 +62,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@ -91,7 +92,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetAllPermissionsByListAsync([FromBody] GetAllPermissionsByListRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
@ -107,7 +107,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the permission by identifier.
|
||||
/// Gets the permission by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -118,14 +118,13 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Read")]
|
||||
public async Task<IActionResult> GetPermissionById([FromBody] GetPermissionRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (request.Id == null || !request.Id.Any())
|
||||
if (request._Id == null || !request._Id.Any())
|
||||
{
|
||||
return BadRequest("Invalid Permission Id");
|
||||
return BadRequest("Invalid Permission _Id");
|
||||
}
|
||||
|
||||
await getPermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
@ -144,7 +143,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> CreatePermissionAsync([FromBody] CreatePermissionRequest newPermission, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -154,7 +152,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full permission by identifier.
|
||||
/// Updates a full permission by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -164,7 +162,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> UpdatePermissionAsync([FromBody] UpdatePermissionRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -173,6 +170,25 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full permission by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> DeletePermissionAsync([FromBody] DeletePermissionRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await deletePermissionHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the status of the permission.
|
||||
/// </summary>
|
||||
@ -185,12 +201,11 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("PermissionManagement.Write")]
|
||||
public async Task<IActionResult> ChangePermissionStatusAsync([FromBody] ChangePermissionStatusRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid permission identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid permission mongo identifier"); }
|
||||
|
||||
await changePermissionStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -1,13 +1,12 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Input;
|
||||
using Core.Cerberos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.Application.UseCases.Roles.Input;
|
||||
using Core.Thalos.Application.UseCases.Roles.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for role authentication.
|
||||
@ -16,13 +15,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class RoleController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<GetRoleRequest> getRoleHandler;
|
||||
private readonly IComponentHandler<GetAllRolesRequest> getAllRolesHandler;
|
||||
private readonly IComponentHandler<CreateRoleRequest> createRoleHandler;
|
||||
private readonly IComponentHandler<UpdateRoleRequest> updateRoleHandler;
|
||||
private readonly IComponentHandler<DeleteRoleRequest> deleteRoleHandler;
|
||||
private readonly IComponentHandler<ChangeRoleStatusRequest> changeStatusRoleHandler;
|
||||
private readonly IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler;
|
||||
private readonly IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler;
|
||||
@ -36,6 +36,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
IComponentHandler<GetAllRolesRequest> getAllRolesHandler,
|
||||
IComponentHandler<CreateRoleRequest> createRoleHandler,
|
||||
IComponentHandler<UpdateRoleRequest> updateRoleHandler,
|
||||
IComponentHandler<DeleteRoleRequest> deleteRoleHandler,
|
||||
IComponentHandler<ChangeRoleStatusRequest> changeRoleStatusHandler,
|
||||
IComponentHandler<AddApplicationToRoleRequest> addApplicationToRoleHandler,
|
||||
IComponentHandler<RemoveApplicationFromRoleRequest> removeApplicationToRoleHandler,
|
||||
@ -44,6 +45,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
{
|
||||
this.createRoleHandler = createRoleHandler;
|
||||
this.updateRoleHandler = updateRoleHandler;
|
||||
this.deleteRoleHandler = deleteRoleHandler;
|
||||
this.changeStatusRoleHandler = changeRoleStatusHandler;
|
||||
this.getAllRolesHandler = getAllRolesHandler;
|
||||
this.getRoleHandler = getRoleHandler;
|
||||
@ -63,7 +65,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllRolesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@ -73,7 +74,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role by identifier.
|
||||
/// Gets the role by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -84,11 +85,10 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetRoleById([FromBody] GetRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role mongo identifier"); }
|
||||
|
||||
await getRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -106,7 +106,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> CreateRoleAsync([FromBody] CreateRoleRequest newRole, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -116,7 +115,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full role by identifier.
|
||||
/// Updates a full role by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -126,7 +125,6 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> UpdateRoleAsync([FromBody] UpdateRoleRequest entity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -135,6 +133,25 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full role by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> DeleteeRoleAsync([FromBody] DeleteRoleRequest entity, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await deleteRoleHandler.ExecuteAsync(entity, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the status of the role.
|
||||
/// </summary>
|
||||
@ -147,11 +164,10 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> ChageRoleStatusAsync(ChangeRoleStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid role identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid role mongo identifier"); }
|
||||
|
||||
await changeStatusRoleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -170,11 +186,10 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> AddApplicationToRoleAsync(AddApplicationToRoleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role mongo identifier"); }
|
||||
|
||||
await addApplicationToRoleHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
@ -193,12 +208,11 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("RoleManagement.Write")]
|
||||
public async Task<IActionResult> RemoveApplicationToRoleAsync(RemoveApplicationFromRoleRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role identifier"); }
|
||||
if (string.IsNullOrEmpty(request.RoleId)) { return BadRequest("Invalid role mongo identifier"); }
|
||||
|
||||
await removeApplicationToRoleHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
176
Core.Thalos.Service.API/Controllers/TenantController.cs
Normal file
176
Core.Thalos.Service.API/Controllers/TenantController.cs
Normal file
@ -0,0 +1,176 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Thalos.Application.UseCases.Tenants.Input;
|
||||
using Core.Thalos.Application.UseCases.Tenants.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="TenantController"/>.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
public class TenantController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<GetTenantRequest> getTenantHandler;
|
||||
private readonly IComponentHandler<GetAllTenantsRequest> getAllTenantsHandler;
|
||||
private readonly IComponentHandler<CreateTenantRequest> createTenantHandler;
|
||||
private readonly IComponentHandler<UpdateTenantRequest> updateTenantHandler;
|
||||
private readonly IComponentHandler<DeleteTenantRequest> deleteTenantHandler;
|
||||
private readonly IComponentHandler<ChangeTenantStatusRequest> changeTenantStatusHandler;
|
||||
private readonly ITenantPort port;
|
||||
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="TenantController"/>.
|
||||
/// </summary>
|
||||
public TenantController(
|
||||
IComponentHandler<GetTenantRequest> getTenantHandler,
|
||||
IComponentHandler<GetAllTenantsRequest> getAllTenantsHandler,
|
||||
IComponentHandler<CreateTenantRequest> createTenantHandler,
|
||||
IComponentHandler<UpdateTenantRequest> updateTenantHandler,
|
||||
IComponentHandler<DeleteTenantRequest> deleteTenantHandler,
|
||||
IComponentHandler<ChangeTenantStatusRequest> changeTenantStatusHandler,
|
||||
ITenantPort port
|
||||
)
|
||||
{
|
||||
this.createTenantHandler = createTenantHandler;
|
||||
this.updateTenantHandler = updateTenantHandler;
|
||||
this.deleteTenantHandler = deleteTenantHandler;
|
||||
this.changeTenantStatusHandler = changeTenantStatusHandler;
|
||||
this.getAllTenantsHandler = getAllTenantsHandler;
|
||||
this.getTenantHandler = getTenantHandler;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all the Tenants.
|
||||
/// </summary>
|
||||
[HttpGet("GetAll")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("TenantManagement.Read, RoleManagement.Read")]
|
||||
public async Task<IActionResult> GetAllTenantsAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllTenantsHandler.ExecuteAsync(new GetAllTenantsRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the Tenant by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("TenantManagement.Read")]
|
||||
public async Task<IActionResult> GetTenantById([FromBody] GetTenantRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (request._Id == null || !request._Id.Any())
|
||||
{
|
||||
return BadRequest("Invalid Tenant _Id");
|
||||
}
|
||||
|
||||
await getTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new Tenant.
|
||||
/// </summary>
|
||||
[HttpPost("Create")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("TenantManagement.Write")]
|
||||
public async Task<IActionResult> CreateTenantAsync([FromBody] CreateTenantRequest newTenant, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createTenantHandler.ExecuteAsync(newTenant, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full Tenant by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("TenantManagement.Write")]
|
||||
public async Task<IActionResult> UpdateTenantAsync([FromBody] UpdateTenantRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await updateTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full Tenant by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Permission("TenantManagement.Write")]
|
||||
public async Task<IActionResult> DeleteTenantAsync([FromBody] DeleteTenantRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await deleteTenantHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the status of the Tenant.
|
||||
/// </summary>
|
||||
[HttpPatch]
|
||||
[Route("ChangeStatus")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Permission("TenantManagement.Write")]
|
||||
public async Task<IActionResult> ChangeTenantStatusAsync([FromBody] ChangeTenantStatusRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid Tenant mongo identifier"); }
|
||||
|
||||
await changeTenantStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,14 +1,12 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Cerberos.Adapters;
|
||||
using Core.Cerberos.Adapters.Attributes;
|
||||
using Core.Cerberos.Adapters.Common.Constants;
|
||||
using Core.Cerberos.Application.UseCases.Users.Input;
|
||||
using Core.Cerberos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.Application.UseCases.Users.Input;
|
||||
using Core.Thalos.Application.UseCases.Users.Ports;
|
||||
using Core.Thalos.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
namespace Core.Thalos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all requests for user.
|
||||
@ -24,17 +22,12 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
private readonly IComponentHandler<GetAllUsersRequest> getAllUsersHandler;
|
||||
private readonly IComponentHandler<CreateUserRequest> createUserHandler;
|
||||
private readonly IComponentHandler<UpdateUserRequest> updateUserHandler;
|
||||
private readonly IComponentHandler<DeleteUserRequest> deleteUserHandler;
|
||||
private readonly IComponentHandler<ChangeUserStatusRequest> ChangeUserStatusHandler;
|
||||
private readonly IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler;
|
||||
private readonly IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler;
|
||||
private readonly IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler;
|
||||
private readonly IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler;
|
||||
private readonly IComponentHandler<LoginUserRequest> loginUserHandler;
|
||||
private readonly IComponentHandler<LogoutUserRequest> logoutUserHandler;
|
||||
private readonly IComponentHandler<ValidateUserExistenceRequest> validateUserHandler;
|
||||
private readonly IComponentHandler<GetTokenAdapterRequest> getTokenAdapterHandler;
|
||||
private readonly IComponentHandler<GetConsentFormPDFRequest> getConsentFormPDFHandler;
|
||||
private readonly IComponentHandler<AcceptUserConsentFormRequest> acceptUserConsentFormHandler;
|
||||
private readonly IUserPort port;
|
||||
|
||||
/// <summary>
|
||||
@ -46,36 +39,26 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
IComponentHandler<GetAllUsersRequest> getAllUsersHandler,
|
||||
IComponentHandler<CreateUserRequest> createUserHandler,
|
||||
IComponentHandler<UpdateUserRequest> updateUserHandler,
|
||||
IComponentHandler<DeleteUserRequest> deleteUserHandler,
|
||||
IComponentHandler<ChangeUserStatusRequest> changeUserStatusHandler,
|
||||
IComponentHandler<AddCompanyToUserRequest> addCompanyToUserHandler,
|
||||
IComponentHandler<RemoveCompanyFromUserRequest> removeCompanyFromUserHandler,
|
||||
IComponentHandler<AddProjectToUserRequest> addProjectToUserHandler,
|
||||
IComponentHandler<RemoveProjectFromUserRequest> removeProjectFromUserHandler,
|
||||
IComponentHandler<LoginUserRequest> loginUserHandler,
|
||||
IComponentHandler<LogoutUserRequest> logoutUserHandler,
|
||||
IComponentHandler<ValidateUserExistenceRequest> validateUserHandler,
|
||||
IComponentHandler<GetTokenAdapterRequest> getTokenAdapterHandler,
|
||||
IComponentHandler<GetConsentFormPDFRequest> getConsentFormPDFHandler,
|
||||
IComponentHandler<AcceptUserConsentFormRequest> acceptUserConsentFormHandler,
|
||||
IUserPort port
|
||||
)
|
||||
{
|
||||
this.createUserHandler = createUserHandler;
|
||||
this.updateUserHandler = updateUserHandler;
|
||||
this.deleteUserHandler = deleteUserHandler;
|
||||
this.ChangeUserStatusHandler = changeUserStatusHandler;
|
||||
this.getAllUsersHandler = getAllUsersHandler;
|
||||
this.getUserHandler = getUserHandler;
|
||||
this.getUserByEmailHandler = getUserByEmailHandler;
|
||||
this.addCompanyToUserHandler = addCompanyToUserHandler;
|
||||
this.removeCompanyFromUserHandler = removeCompanyFromUserHandler;
|
||||
this.addProjectToUserHandler = addProjectToUserHandler;
|
||||
this.removeProjectFromUserHandler = removeProjectFromUserHandler;
|
||||
this.loginUserHandler = loginUserHandler;
|
||||
this.logoutUserHandler = logoutUserHandler;
|
||||
this.validateUserHandler = validateUserHandler;
|
||||
this.getTokenAdapterHandler = getTokenAdapterHandler;
|
||||
this.getConsentFormPDFHandler = getConsentFormPDFHandler;
|
||||
this.acceptUserConsentFormHandler = acceptUserConsentFormHandler;
|
||||
this.port = port;
|
||||
}
|
||||
/// <summary>
|
||||
@ -90,7 +73,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetAllUsersAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
@ -100,7 +83,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the user by identifier.
|
||||
/// Gets the user by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -111,11 +94,11 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetUserById([FromBody] GetUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user mongo identifier"); }
|
||||
|
||||
await getUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
@ -134,7 +117,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
|
||||
public async Task<IActionResult> GetUserByEmail([FromBody] GetUserByEmailRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@ -156,7 +139,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> CreateUserAsync([FromBody] CreateUserRequest newUser, CancellationToken cancellationToken = default)
|
||||
{
|
||||
@ -166,7 +149,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full user by identifier.
|
||||
/// Updates a full user by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -176,7 +159,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> UpdateUserAsync([FromBody] UpdateUserRequest request,
|
||||
CancellationToken cancellationToken = default)
|
||||
@ -186,6 +169,27 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a full user by mongo identifier.
|
||||
/// </summary>
|
||||
[HttpDelete("Delete")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> DeleteUserAsync([FromBody] DeleteUserRequest request,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
await deleteUserHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs in the user.
|
||||
/// </summary>
|
||||
@ -197,7 +201,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
|
||||
public async Task<IActionResult> LoginUserAsync([FromBody] LoginUserRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@ -239,118 +243,17 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.DefaultScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> ChangeUserStatusAsync([FromBody] ChangeUserStatusRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid user mongo identifier"); }
|
||||
|
||||
await ChangeUserStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a company to the user's list of companies.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("AddCompany")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> AddCompanyToUserAsync([FromBody] AddCompanyToUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||
|
||||
await addCompanyToUserHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a company from the user's list of companies.
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
[Route("RemoveCompany")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveCompanyFromUserAsync([FromBody] RemoveCompanyFromUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.CompanyId)) { return BadRequest("Invalid company identifier"); }
|
||||
|
||||
await removeCompanyFromUserHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a project to the user's list of projects.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("AddProject")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> AddProjectToUserAsync([FromBody] AddProjectToUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||
|
||||
await addProjectToUserHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Removes a project from the user's list of projects.
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
[Route("RemoveProject")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Write")]
|
||||
public async Task<IActionResult> RemoveProjectFromUserAsync([FromBody] RemoveProjectFromUserRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(request.UserId)) { return BadRequest("Invalid user identifier"); }
|
||||
if (string.IsNullOrEmpty(request.ProjectId)) { return BadRequest("Invalid project identifier"); }
|
||||
|
||||
await removeProjectFromUserHandler.ExecuteAsync(request, cancellationToken);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validates if a user exists on the database.
|
||||
/// </summary>
|
||||
@ -379,7 +282,7 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[HttpPost]
|
||||
[Route("GetTokenAdapter")]
|
||||
[ProducesResponseType(typeof(TokenAdapter), StatusCodes.Status200OK)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.DefaultScheme}, {Schemes.GoogleScheme}")]
|
||||
public async Task<IActionResult> GetTokenAdapter([FromBody] GetTokenAdapterRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Email)) { return BadRequest("Invalid user email"); }
|
||||
@ -388,45 +291,5 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get Consent Form PDF.
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
[Route("GetConsentFormPDF")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[Authorize(AuthenticationSchemes = Schemes.HeathScheme)]
|
||||
[Permission("UserManagement.Read")]
|
||||
public async Task<IActionResult> GetConsentFormPDFAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getConsentFormPDFHandler.ExecuteAsync(new GetConsentFormPDFRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Accept user consent form.
|
||||
/// </summary>
|
||||
[HttpPatch("AcceptUserConsentForm")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[Authorize(AuthenticationSchemes = $"{Schemes.HeathScheme}, {Schemes.AzureScheme}")]
|
||||
public async Task<IActionResult> AcceptUserConsentFormAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await acceptUserConsentFormHandler.ExecuteAsync(new AcceptUserConsentFormRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user