Create general structures in Mongo and SQL
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.KeyVault.Input
|
||||
namespace Core.Blueprint.Application.UsesCases.BlobStorage.Input
|
||||
{
|
||||
public class DeleteBlobRequest : Notificator, ICommand
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.KeyVault.Input
|
||||
namespace Core.Blueprint.Application.UsesCases.BlobStorage.Input
|
||||
{
|
||||
public class DownloadBlobRequest : Notificator, ICommand
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.KeyVault.Input
|
||||
namespace Core.Blueprint.Application.UsesCases.BlobStorage.Input
|
||||
{
|
||||
public class GetBlobListRequest : Notificator, ICommand
|
||||
{
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.KeyVault.Input
|
||||
namespace Core.Blueprint.Application.UsesCases.BlobStorage.Input
|
||||
{
|
||||
public class UploadBlobRequest : Notificator, ICommand
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
|
||||
using Core.Blueprint.Service.External.Clients;
|
||||
using Core.Blueprint.Storage;
|
||||
using FluentValidation;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.KeyVault.Validator
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.KeyVault.Validator
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.KeyVault.Validator
|
||||
|
||||
@@ -4,7 +4,7 @@ using Core.Blueprint.Service.External.Clients.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.MongoStorage.Adapter
|
||||
namespace Core.Blueprint.Application.UsesCases.KeyVault.Adapter
|
||||
{
|
||||
public class KeyVaultPort : BasePresenter, IKeyVaultPort
|
||||
{
|
||||
|
||||
@@ -3,15 +3,15 @@ using Core.Blueprint.Service.External.Clients.Adapters;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.MongoStorage.Adapter
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Adapter
|
||||
{
|
||||
public class MongoPort : BasePresenter, IMongoPort
|
||||
{
|
||||
public void Success(BlueprintAdapter output)
|
||||
public void Success(MongoSampleAdapter output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
public void Success(List<BlueprintAdapter> output)
|
||||
public void Success(List<MongoSampleAdapter> output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Input
|
||||
{
|
||||
public class CreateBlueprintRequest : Notificator, ICommand
|
||||
public class CreateMongoSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Input
|
||||
{
|
||||
public class DeleteBlueprintRequest : Notificator, ICommand
|
||||
public class DeleteMongoSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Input
|
||||
{
|
||||
public class GetAllBlueprintsRequest : Notificator, ICommand
|
||||
public class GetAllMongoSamplesRequest : Notificator, ICommand
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Input
|
||||
{
|
||||
public class GetBlueprintRequest : Notificator, ICommand
|
||||
public class GetMongoSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string _Id { get; set; }
|
||||
|
||||
@@ -3,7 +3,7 @@ using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Input
|
||||
{
|
||||
public class UpdateBlueprintRequest : Notificator, ICommand
|
||||
public class UpdateMongoSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
@@ -7,57 +7,57 @@ using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo
|
||||
{
|
||||
public class MongoHandler :
|
||||
IComponentHandler<CreateBlueprintRequest>,
|
||||
IComponentHandler<GetBlueprintRequest>,
|
||||
IComponentHandler<GetAllBlueprintsRequest>,
|
||||
IComponentHandler<UpdateBlueprintRequest>,
|
||||
IComponentHandler<DeleteBlueprintRequest>
|
||||
IComponentHandler<CreateMongoSampleRequest>,
|
||||
IComponentHandler<GetMongoSampleRequest>,
|
||||
IComponentHandler<GetAllMongoSamplesRequest>,
|
||||
IComponentHandler<UpdateMongoSampleRequest>,
|
||||
IComponentHandler<DeleteMongoSampleRequest>
|
||||
{
|
||||
private readonly IMongoPort _port;
|
||||
private readonly IValidator<CreateBlueprintRequest> _createBlueprintValidator;
|
||||
private readonly IValidator<GetBlueprintRequest> _getBlueprintValidator;
|
||||
private readonly IValidator<UpdateBlueprintRequest> _updateBlueprintValidator;
|
||||
private readonly IValidator<DeleteBlueprintRequest> _deleteBlueprintValidator;
|
||||
private readonly IBlueprintServiceClient _mongoDALService;
|
||||
private readonly IValidator<CreateMongoSampleRequest> _createSampleValidator;
|
||||
private readonly IValidator<GetMongoSampleRequest> _getSampleValidator;
|
||||
private readonly IValidator<UpdateMongoSampleRequest> _updateSampleValidator;
|
||||
private readonly IValidator<DeleteMongoSampleRequest> _deleteSampleValidator;
|
||||
private readonly IBlueprintServiceClient _blueprintServiceClient;
|
||||
|
||||
public MongoHandler(
|
||||
IMongoPort port,
|
||||
IValidator<CreateBlueprintRequest> createBlueprintValidator,
|
||||
IValidator<GetBlueprintRequest> getBlueprintValidator,
|
||||
IValidator<UpdateBlueprintRequest> updateBlueprintValidator,
|
||||
IValidator<DeleteBlueprintRequest> deleteBlueprintValidator,
|
||||
IBlueprintServiceClient mongoDALService)
|
||||
IValidator<CreateMongoSampleRequest> createSampleValidator,
|
||||
IValidator<GetMongoSampleRequest> getSampleValidator,
|
||||
IValidator<UpdateMongoSampleRequest> updateSampleValidator,
|
||||
IValidator<DeleteMongoSampleRequest> deleteSampleValidator,
|
||||
IBlueprintServiceClient blueprintServiceClient)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_createBlueprintValidator = createBlueprintValidator ?? throw new ArgumentNullException(nameof(createBlueprintValidator));
|
||||
_getBlueprintValidator = getBlueprintValidator ?? throw new ArgumentNullException(nameof(getBlueprintValidator));
|
||||
_updateBlueprintValidator = updateBlueprintValidator ?? throw new ArgumentNullException(nameof(updateBlueprintValidator));
|
||||
_deleteBlueprintValidator = deleteBlueprintValidator ?? throw new ArgumentNullException(nameof(deleteBlueprintValidator));
|
||||
_mongoDALService = mongoDALService ?? throw new ArgumentNullException(nameof(mongoDALService));
|
||||
_createSampleValidator = createSampleValidator ?? throw new ArgumentNullException(nameof(createSampleValidator));
|
||||
_getSampleValidator = getSampleValidator ?? throw new ArgumentNullException(nameof(getSampleValidator));
|
||||
_updateSampleValidator = updateSampleValidator ?? throw new ArgumentNullException(nameof(updateSampleValidator));
|
||||
_deleteSampleValidator = deleteSampleValidator ?? throw new ArgumentNullException(nameof(deleteSampleValidator));
|
||||
_blueprintServiceClient = blueprintServiceClient ?? throw new ArgumentNullException(nameof(blueprintServiceClient));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(CreateBlueprintRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(CreateMongoSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_createBlueprintValidator))
|
||||
if (!command.IsValid(_createSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new BlueprintRequest
|
||||
var request = new MongoSampleRequest
|
||||
{
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
};
|
||||
|
||||
var result = await _mongoDALService.CreateBlueprintAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _blueprintServiceClient.CreateMongoSampleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -73,13 +73,13 @@ namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetAllBlueprintsRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(GetAllMongoSamplesRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _mongoDALService.GetAllBlueprintsAsync().ConfigureAwait(false);
|
||||
var _result = await _blueprintServiceClient.GetAllMongoSamplesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -93,19 +93,19 @@ namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetBlueprintRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(GetMongoSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_getBlueprintValidator))
|
||||
if (!command.IsValid(_getSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _mongoDALService.GetBlueprintByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _blueprintServiceClient.GetMongoSampleByIdAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -122,19 +122,19 @@ namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask ExecuteAsync(UpdateBlueprintRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(UpdateMongoSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_updateBlueprintValidator))
|
||||
if (!command.IsValid(_updateSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new BlueprintAdapter
|
||||
var request = new MongoSampleAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
_Id = command._Id,
|
||||
@@ -149,7 +149,7 @@ namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
|
||||
string _id = command._Id;
|
||||
|
||||
var result = await _mongoDALService.UpdateBlueprintAsync(_id, request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _blueprintServiceClient.UpdateMongoSampleAsync(_id, request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -166,19 +166,19 @@ namespace Core.Cerberos.Application.UseCases.Blueprints
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteBlueprintRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(DeleteMongoSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_deleteBlueprintValidator))
|
||||
if (!command.IsValid(_deleteSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _mongoDALService.DeleteBlueprintAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _blueprintServiceClient.DeleteMongoSampleAsync(command._Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ using Lib.Architecture.BuildingBlocks;
|
||||
namespace Core.Blueprint.Application.UsesCases.Mongo.Ports
|
||||
{
|
||||
public interface IMongoPort : IBasePort,
|
||||
ICommandSuccessPort<BlueprintAdapter>,
|
||||
ICommandSuccessPort<List<BlueprintAdapter>>,
|
||||
ICommandSuccessPort<MongoSampleAdapter>,
|
||||
ICommandSuccessPort<List<MongoSampleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Blueprints.Validator
|
||||
{
|
||||
public class CreateBlueprintValidator : AbstractValidator<CreateBlueprintRequest>
|
||||
{
|
||||
public CreateBlueprintValidator()
|
||||
{
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Blueprint Name").WithMessage("Blueprint Name is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Mongo.Validator
|
||||
{
|
||||
public class CreateMongoSampleValidator : AbstractValidator<CreateMongoSampleRequest>
|
||||
{
|
||||
public CreateMongoSampleValidator()
|
||||
{
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Sample Name").WithMessage("Sample Name is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Blueprints.Validator
|
||||
{
|
||||
public class DeleteBlueprintValidator : AbstractValidator<DeleteBlueprintRequest>
|
||||
{
|
||||
public DeleteBlueprintValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Blueprint Mongo Identifier").WithMessage("Blueprint Mongo Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Mongo.Validator
|
||||
{
|
||||
public class DeleteMongoSampleValidator : AbstractValidator<DeleteMongoSampleRequest>
|
||||
{
|
||||
public DeleteMongoSampleValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Sample Identifier").WithMessage("Sample Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Blueprints.Validator
|
||||
{
|
||||
public class GetBlueprintValidator : AbstractValidator<GetBlueprintRequest>
|
||||
{
|
||||
public GetBlueprintValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Blueprint Mongo Identifier").WithMessage("Blueprint Mongo Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Mongo.Validator
|
||||
{
|
||||
public class GetMongoSampleValidator : AbstractValidator<GetMongoSampleRequest>
|
||||
{
|
||||
public GetMongoSampleValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Sample Identifier").WithMessage("Sample Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Blueprints.Validator
|
||||
{
|
||||
public class UpdateBlueprintValidator : AbstractValidator<UpdateBlueprintRequest>
|
||||
{
|
||||
public UpdateBlueprintValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Blueprint Mongo Identifier").WithMessage("Blueprint Mongo Identifier is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Blueprint GUID").WithMessage("Blueprint GUID is Obligatory.");
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Blueprint Name").WithMessage("Blueprint Name is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Blueprint Status").WithMessage("Blueprint Status is Obligatory.");
|
||||
RuleFor(i => i.CreatedAt).NotNull().OverridePropertyName(x => x.CreatedAt).WithName("Blueprint CreatedAt").WithMessage("Blueprint CreatedAt is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.Mongo.Validator
|
||||
{
|
||||
public class UpdateMongoSampleValidator : AbstractValidator<UpdateMongoSampleRequest>
|
||||
{
|
||||
public UpdateMongoSampleValidator()
|
||||
{
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x._Id).WithName("Sample Identifier").WithMessage("Sample Identifier is Obligatory.");
|
||||
RuleFor(i => i._Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Sample GUID").WithMessage("Sample GUID is Obligatory.");
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Sample Name").WithMessage("Sample Name is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Sample Status").WithMessage("Sample Status is Obligatory.");
|
||||
RuleFor(i => i.CreatedAt).NotNull().OverridePropertyName(x => x.CreatedAt).WithName("Sample CreatedAt").WithMessage("Sample CreatedAt is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,11 @@ namespace Core.Blueprint.Application.UsesCases.SQL.Adapter
|
||||
{
|
||||
public class SQLPort : BasePresenter, ISQLPort
|
||||
{
|
||||
public void Success(UserProjectAdapter output)
|
||||
public void Success(SqlSampleAdapter output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
public void Success(List<UserProjectAdapter> output)
|
||||
public void Success(List<SqlSampleAdapter> output)
|
||||
{
|
||||
ViewModel = new OkObjectResult(output);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class CreateSqlSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return Name != null && Name != string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class CreateUserProjectRequest : Notificator, ICommand
|
||||
{
|
||||
public string ProjectCode { get; set; } = null!;
|
||||
public string ProjectDescription { get; set; } = null!;
|
||||
public string UserId { get; set; } = null!;
|
||||
|
||||
public bool Validate()
|
||||
{
|
||||
return ProjectCode != null && ProjectCode != string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class DeleteUserProjectRequest : Notificator, ICommand
|
||||
public class DeleteSqlSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class GetAllUserProjectsRequest : Notificator, ICommand
|
||||
public class GetAllSqlSamplesRequest : Notificator, ICommand
|
||||
{
|
||||
public bool Validate()
|
||||
{
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class GetUserProjectRequest : Notificator, ICommand
|
||||
public class GetSqlSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
@@ -3,11 +3,10 @@ using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Input
|
||||
{
|
||||
public class UpdateUserProjectRequest : Notificator, ICommand
|
||||
public class UpdateSqlSampleRequest : Notificator, ICommand
|
||||
{
|
||||
public string ProjectCode { get; set; } = null!;
|
||||
public string ProjectDescription { get; set; } = null!;
|
||||
public string UserId { get; set; } = null!;
|
||||
public string Name { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public int Id { get; set; }
|
||||
public string Guid { get; set; } = null!;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
@@ -4,8 +4,8 @@ using Lib.Architecture.BuildingBlocks;
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL.Ports
|
||||
{
|
||||
public interface ISQLPort : IBasePort,
|
||||
ICommandSuccessPort<UserProjectAdapter>,
|
||||
ICommandSuccessPort<List<UserProjectAdapter>>,
|
||||
ICommandSuccessPort<SqlSampleAdapter>,
|
||||
ICommandSuccessPort<List<SqlSampleAdapter>>,
|
||||
INoContentPort, IBusinessErrorPort, ITimeoutPort, IValidationErrorPort,
|
||||
INotFoundPort, IForbiddenPort, IUnauthorizedPort, IInternalServerErrorPort,
|
||||
IBadRequestPort
|
||||
|
||||
@@ -7,58 +7,57 @@ using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
using Lib.Architecture.BuildingBlocks.Helpers;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
namespace Core.Blueprint.Application.UsesCases.SQL
|
||||
{
|
||||
public class SQLHandler :
|
||||
IComponentHandler<CreateUserProjectRequest>,
|
||||
IComponentHandler<GetUserProjectRequest>,
|
||||
IComponentHandler<GetAllUserProjectsRequest>,
|
||||
IComponentHandler<UpdateUserProjectRequest>,
|
||||
IComponentHandler<DeleteUserProjectRequest>
|
||||
IComponentHandler<CreateSqlSampleRequest>,
|
||||
IComponentHandler<GetSqlSampleRequest>,
|
||||
IComponentHandler<GetAllSqlSamplesRequest>,
|
||||
IComponentHandler<UpdateSqlSampleRequest>,
|
||||
IComponentHandler<DeleteSqlSampleRequest>
|
||||
{
|
||||
private readonly ISQLPort _port;
|
||||
private readonly IValidator<CreateUserProjectRequest> _createUserProjectValidator;
|
||||
private readonly IValidator<GetUserProjectRequest> _getUserProjectValidator;
|
||||
private readonly IValidator<UpdateUserProjectRequest> _updateUserProjectValidator;
|
||||
private readonly IValidator<DeleteUserProjectRequest> _deleteUserProjectValidator;
|
||||
private readonly IValidator<CreateSqlSampleRequest> _createSampleValidator;
|
||||
private readonly IValidator<GetSqlSampleRequest> _getSampleValidator;
|
||||
private readonly IValidator<UpdateSqlSampleRequest> _updateSampleValidator;
|
||||
private readonly IValidator<DeleteSqlSampleRequest> _deleteSampleValidator;
|
||||
private readonly IBlueprintServiceClient _SQLDALService;
|
||||
|
||||
public SQLHandler(
|
||||
ISQLPort port,
|
||||
IValidator<CreateUserProjectRequest> createUserProjectValidator,
|
||||
IValidator<GetUserProjectRequest> getUserProjectValidator,
|
||||
IValidator<UpdateUserProjectRequest> updateUserProjectValidator,
|
||||
IValidator<DeleteUserProjectRequest> deleteUserProjectValidator,
|
||||
IValidator<CreateSqlSampleRequest> createSampleValidator,
|
||||
IValidator<GetSqlSampleRequest> getSampleValidator,
|
||||
IValidator<UpdateSqlSampleRequest> updateSampleValidator,
|
||||
IValidator<DeleteSqlSampleRequest> deleteSampleValidator,
|
||||
IBlueprintServiceClient SQLDALService)
|
||||
{
|
||||
_port = port ?? throw new ArgumentNullException(nameof(port));
|
||||
_createUserProjectValidator = createUserProjectValidator ?? throw new ArgumentNullException(nameof(createUserProjectValidator));
|
||||
_getUserProjectValidator = getUserProjectValidator ?? throw new ArgumentNullException(nameof(getUserProjectValidator));
|
||||
_updateUserProjectValidator = updateUserProjectValidator ?? throw new ArgumentNullException(nameof(updateUserProjectValidator));
|
||||
_deleteUserProjectValidator = deleteUserProjectValidator ?? throw new ArgumentNullException(nameof(deleteUserProjectValidator));
|
||||
_createSampleValidator = createSampleValidator ?? throw new ArgumentNullException(nameof(createSampleValidator));
|
||||
_getSampleValidator = getSampleValidator ?? throw new ArgumentNullException(nameof(getSampleValidator));
|
||||
_updateSampleValidator = updateSampleValidator ?? throw new ArgumentNullException(nameof(updateSampleValidator));
|
||||
_deleteSampleValidator = deleteSampleValidator ?? throw new ArgumentNullException(nameof(deleteSampleValidator));
|
||||
_SQLDALService = SQLDALService ?? throw new ArgumentNullException(nameof(SQLDALService));
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(CreateUserProjectRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(CreateSqlSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_createUserProjectValidator))
|
||||
if (!command.IsValid(_createSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new UserProjectRequest
|
||||
var request = new SqlSampleRequest
|
||||
{
|
||||
ProjectCode = command.ProjectCode,
|
||||
ProjectDescription = command.ProjectDescription,
|
||||
UserId = command.UserId,
|
||||
Name = command.Name,
|
||||
Description = command.Description,
|
||||
};
|
||||
|
||||
var result = await _SQLDALService.CreateUserProjectAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _SQLDALService.CreateSqlSampleAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -74,13 +73,13 @@ namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetAllUserProjectsRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(GetAllSqlSamplesRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var _result = await _SQLDALService.GetAllUserProjectsAsync().ConfigureAwait(false);
|
||||
var _result = await _SQLDALService.GetAllSqlSamplesAsync().ConfigureAwait(false);
|
||||
if (!_result.Any())
|
||||
{
|
||||
_port.NoContentSuccess();
|
||||
@@ -94,13 +93,19 @@ namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
}
|
||||
}
|
||||
|
||||
public async ValueTask ExecuteAsync(GetUserProjectRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(GetSqlSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
var result = await _SQLDALService.GetUserProjectByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
if (!command.IsValid(_getSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _SQLDALService.GetSqlSampleByIdAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -117,25 +122,24 @@ namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask ExecuteAsync(UpdateUserProjectRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(UpdateSqlSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_updateUserProjectValidator))
|
||||
if (!command.IsValid(_updateSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var request = new UserProjectAdapter
|
||||
var request = new SqlSampleAdapter
|
||||
{
|
||||
Id = command.Id,
|
||||
Guid = command.Guid,
|
||||
UserId = command.UserId,
|
||||
ProjectCode = command.ProjectCode,
|
||||
ProjectDescription = command.ProjectDescription,
|
||||
ProjectCode = command.Name,
|
||||
ProjectDescription = command.Description,
|
||||
CreatedAt = command.CreatedAt,
|
||||
CreatedBy = command.CreatedBy,
|
||||
UpdatedAt = command.UpdatedAt,
|
||||
@@ -145,7 +149,7 @@ namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
|
||||
int id = command.Id;
|
||||
|
||||
var result = await _SQLDALService.UpdateUserProjectAsync(id, request, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _SQLDALService.UpdateSqlSampleAsync(id, request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
@@ -162,19 +166,19 @@ namespace Core.Cerberos.Application.UseCases.UserProjects
|
||||
}
|
||||
|
||||
|
||||
public async ValueTask ExecuteAsync(DeleteUserProjectRequest command, CancellationToken cancellationToken = default)
|
||||
public async ValueTask ExecuteAsync(DeleteSqlSampleRequest command, CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(command);
|
||||
|
||||
if (!command.IsValid(_deleteUserProjectValidator))
|
||||
if (!command.IsValid(_deleteSampleValidator))
|
||||
{
|
||||
_port.ValidationErrors(command.Notifications);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = await _SQLDALService.DeleteUserProjectAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
var result = await _SQLDALService.DeleteSqlSampleAsync(command.Id, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
if (result == null)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class CreateSqlSampleValidator : AbstractValidator<CreateSqlSampleRequest>
|
||||
{
|
||||
public CreateSqlSampleValidator()
|
||||
{
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Sample Name").WithMessage("Sample Name is Obligatory.");
|
||||
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Sample Description").WithMessage("Sample Description is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class CreateUserProjectValidator : AbstractValidator<CreateUserProjectRequest>
|
||||
{
|
||||
public CreateUserProjectValidator()
|
||||
{
|
||||
RuleFor(i => i.ProjectCode).NotEmpty().NotNull().OverridePropertyName(x => x.ProjectCode).WithName("Project Code").WithMessage("Project Code is Obligatory.");
|
||||
RuleFor(i => i.ProjectDescription).NotEmpty().NotNull().OverridePropertyName(x => x.ProjectDescription).WithName("Project Description").WithMessage("Project Description is Obligatory.");
|
||||
RuleFor(i => i.UserId).NotEmpty().NotNull().OverridePropertyName(x => x.UserId).WithName("User Identifier").WithMessage("User Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,11 @@ using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class GetUserProjectValidator : AbstractValidator<GetUserProjectRequest>
|
||||
public class DeleteSqlSampleValidator : AbstractValidator<DeleteSqlSampleRequest>
|
||||
{
|
||||
public GetUserProjectValidator()
|
||||
public DeleteSqlSampleValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("User Project Identifier").WithMessage("User Project Identifier is Obligatory.");
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Sample Identifier").WithMessage("Sample Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class DeleteUserProjectValidator : AbstractValidator<DeleteUserProjectRequest>
|
||||
{
|
||||
public DeleteUserProjectValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("User Project Identifier").WithMessage("User Project Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class GetSqlSampleValidator : AbstractValidator<GetSqlSampleRequest>
|
||||
{
|
||||
public GetSqlSampleValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Sample Identifier").WithMessage("Sample Identifier is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class UpdateSqlSampleValidator : AbstractValidator<UpdateSqlSampleRequest>
|
||||
{
|
||||
public UpdateSqlSampleValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("Sample Identifier").WithMessage("UserPoject Identifier is Obligatory.");
|
||||
RuleFor(i => i.Guid).NotEmpty().NotNull().OverridePropertyName(x => x.Guid).WithName("Sample GUID").WithMessage("Sample GUID is Obligatory.");
|
||||
RuleFor(i => i.Name).NotEmpty().NotNull().OverridePropertyName(x => x.Name).WithName("Sample Name").WithMessage("Sample Name is Obligatory.");
|
||||
RuleFor(i => i.Description).NotEmpty().NotNull().OverridePropertyName(x => x.Description).WithName("Project Description").WithMessage("Project Description is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("Sample Status").WithMessage("Sample Status is Obligatory.");
|
||||
RuleFor(i => i.CreatedAt).NotNull().OverridePropertyName(x => x.CreatedAt).WithName("Sample CreatedAt").WithMessage("Sample CreatedAt is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using FluentValidation;
|
||||
|
||||
namespace Core.Cerberos.Application.UseCases.SQL.Validator
|
||||
{
|
||||
public class UpdateUserProjectValidator : AbstractValidator<UpdateUserProjectRequest>
|
||||
{
|
||||
public UpdateUserProjectValidator()
|
||||
{
|
||||
RuleFor(i => i.Id).NotEmpty().NotNull().OverridePropertyName(x => x.Id).WithName("UserProject Identifier").WithMessage("UserPoject Identifier is Obligatory.");
|
||||
RuleFor(i => i.Guid).NotEmpty().NotNull().OverridePropertyName(x => x.Guid).WithName("UserProject GUID").WithMessage("UserProject GUID is Obligatory.");
|
||||
RuleFor(i => i.ProjectCode).NotEmpty().NotNull().OverridePropertyName(x => x.ProjectCode).WithName("Project Code").WithMessage("Project Code is Obligatory.");
|
||||
RuleFor(i => i.ProjectDescription).NotEmpty().NotNull().OverridePropertyName(x => x.ProjectDescription).WithName("Project Description").WithMessage("Project Description is Obligatory.");
|
||||
RuleFor(i => i.UserId).NotEmpty().NotNull().OverridePropertyName(x => x.UserId).WithName("User Identifier").WithMessage("User Identifier is Obligatory.");
|
||||
RuleFor(i => i.Status).NotNull().OverridePropertyName(x => x.Status).WithName("UserProject Status").WithMessage("UserProject Status is Obligatory.");
|
||||
RuleFor(i => i.CreatedAt).NotNull().OverridePropertyName(x => x.CreatedAt).WithName("UserProject CreatedAt").WithMessage("UserProject CreatedAt is Obligatory.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user