Compare commits
5 Commits
b2635193dc
...
465e5bb1fc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
465e5bb1fc | ||
|
|
889365baa6 | ||
|
|
c7953250fc | ||
|
|
144a6c14c0 | ||
|
|
c7ff7b8c18 |
@ -11,8 +11,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
|
||||
<PackageReference Include="Core.Blueprint.KeyVault" Version="0.3.0-alpha0037" />
|
||||
<PackageReference Include="MongoDB.Bson" Version="3.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using Asp.Versioning;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
@ -7,43 +7,43 @@ using Microsoft.AspNetCore.Mvc;
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="MongoBlueprintController"/>.
|
||||
/// Handles all services and business rules related to <see cref="MongoSampleController"/>.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
public class MongoBlueprintController : ControllerBase
|
||||
public class MongoSampleController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<CreateBlueprintRequest> createBlueprintHandler;
|
||||
private readonly IComponentHandler<GetAllBlueprintsRequest> getAllBlueprintsHandler;
|
||||
private readonly IComponentHandler<GetBlueprintRequest> getBlueprintHandler;
|
||||
private readonly IComponentHandler<UpdateBlueprintRequest> updateBlueprintHandler;
|
||||
private readonly IComponentHandler<DeleteBlueprintRequest> deleteBlueprintHandler;
|
||||
private readonly IComponentHandler<CreateMongoSampleRequest> createSampleHandler;
|
||||
private readonly IComponentHandler<GetAllMongoSamplesRequest> getAllSamplesHandler;
|
||||
private readonly IComponentHandler<GetMongoSampleRequest> getSampleHandler;
|
||||
private readonly IComponentHandler<UpdateMongoSampleRequest> updateSampleHandler;
|
||||
private readonly IComponentHandler<DeleteMongoSampleRequest> deleteSampleHandler;
|
||||
private readonly IMongoPort port;
|
||||
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="MongoBlueprintController"/>.
|
||||
/// Handles all services and business rules related to <see cref="MongoSampleController"/>.
|
||||
/// </summary>
|
||||
public MongoBlueprintController(
|
||||
IComponentHandler<GetBlueprintRequest> getBlueprintHandler,
|
||||
IComponentHandler<GetAllBlueprintsRequest> getAllBlueprintsHandler,
|
||||
IComponentHandler<CreateBlueprintRequest> createBlueprintHandler,
|
||||
IComponentHandler<UpdateBlueprintRequest> updateBlueprintHandler,
|
||||
IComponentHandler<DeleteBlueprintRequest> deleteBlueprintHandler,
|
||||
public MongoSampleController(
|
||||
IComponentHandler<GetMongoSampleRequest> getSampleHandler,
|
||||
IComponentHandler<GetAllMongoSamplesRequest> getAllSamplesHandler,
|
||||
IComponentHandler<CreateMongoSampleRequest> createSampleHandler,
|
||||
IComponentHandler<UpdateMongoSampleRequest> updateSampleHandler,
|
||||
IComponentHandler<DeleteMongoSampleRequest> deleteSampleHandler,
|
||||
IMongoPort port
|
||||
)
|
||||
{
|
||||
this.createBlueprintHandler = createBlueprintHandler;
|
||||
this.updateBlueprintHandler = updateBlueprintHandler;
|
||||
this.deleteBlueprintHandler = deleteBlueprintHandler;
|
||||
this.getAllBlueprintsHandler = getAllBlueprintsHandler;
|
||||
this.getBlueprintHandler = getBlueprintHandler;
|
||||
this.createSampleHandler = createSampleHandler;
|
||||
this.updateSampleHandler = updateSampleHandler;
|
||||
this.deleteSampleHandler = deleteSampleHandler;
|
||||
this.getAllSamplesHandler = getAllSamplesHandler;
|
||||
this.getSampleHandler = getSampleHandler;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new blueprint.
|
||||
/// Creates a new sample.
|
||||
/// </summary>
|
||||
[HttpPost("Create")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -53,14 +53,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> CreateBlueprintAsync([FromBody] CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken = default)
|
||||
public async Task<IActionResult> CreateSampleAsync([FromBody] CreateMongoSampleRequest newSample, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createBlueprintHandler.ExecuteAsync(newBlueprint, cancellationToken).ConfigureAwait(false);
|
||||
await createSampleHandler.ExecuteAsync(newSample, cancellationToken).ConfigureAwait(false);
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all blueprints.
|
||||
/// Gets all samples.
|
||||
/// </summary>
|
||||
[HttpGet("GetAll")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -70,14 +70,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> GetAllBlueprintsAsync(CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> GetAllSamplesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllBlueprintsHandler.ExecuteAsync(new GetAllBlueprintsRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
await getAllSamplesHandler.ExecuteAsync(new GetAllMongoSamplesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the blueprint by identifier.
|
||||
/// Gets the sample by identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -88,17 +88,17 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetBlueprintById([FromBody] GetBlueprintRequest request, CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> GetSampleById([FromBody] GetMongoSampleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid sample identifier"); }
|
||||
|
||||
await getBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await getSampleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full blueprint by identifier.
|
||||
/// Updates a full sample by identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -108,17 +108,17 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> UpdateBlueprintAsync([FromBody] UpdateBlueprintRequest request, CancellationToken cancellationToken = default)
|
||||
public async Task<IActionResult> UpdateSampleAsync([FromBody] UpdateMongoSampleRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid sample identifier"); }
|
||||
|
||||
await updateBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await updateSampleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a blueprint.
|
||||
/// Deletes a sample.
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
[Route("Delete")]
|
||||
@ -129,12 +129,12 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteBlueprintAsync([FromBody] DeleteBlueprintRequest request,
|
||||
public async Task<IActionResult> DeleteSampleAsync([FromBody] DeleteMongoSampleRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid blueprint identifier"); }
|
||||
if (string.IsNullOrEmpty(request._Id)) { return BadRequest("Invalid sample identifier"); }
|
||||
|
||||
await deleteBlueprintHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await deleteSampleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
@ -7,43 +7,43 @@ using Microsoft.AspNetCore.Mvc;
|
||||
namespace Core.Cerberos.Service.API.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="SQLUserProjectController"/>.
|
||||
/// Handles all services and business rules related to <see cref="SqlSampleController"/>.
|
||||
/// </summary>
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/v{api-version:apiVersion}/[controller]")]
|
||||
[Produces("application/json")]
|
||||
[ApiController]
|
||||
public class SQLUserProjectController : ControllerBase
|
||||
public class SqlSampleController : ControllerBase
|
||||
{
|
||||
private readonly IComponentHandler<CreateUserProjectRequest> createUserProjectHandler;
|
||||
private readonly IComponentHandler<GetAllUserProjectsRequest> getAllUserProjectsHandler;
|
||||
private readonly IComponentHandler<GetUserProjectRequest> getUserProjectHandler;
|
||||
private readonly IComponentHandler<UpdateUserProjectRequest> updateUserProjectHandler;
|
||||
private readonly IComponentHandler<DeleteUserProjectRequest> deleteUserProjectStatusHandler;
|
||||
private readonly IComponentHandler<CreateSqlSampleRequest> createSampleHandler;
|
||||
private readonly IComponentHandler<GetAllSqlSamplesRequest> getAllSamplesHandler;
|
||||
private readonly IComponentHandler<GetSqlSampleRequest> getSampleHandler;
|
||||
private readonly IComponentHandler<UpdateSqlSampleRequest> updateSampleHandler;
|
||||
private readonly IComponentHandler<DeleteSqlSampleRequest> deleteSampleStatusHandler;
|
||||
private readonly ISQLPort port;
|
||||
|
||||
/// <summary>
|
||||
/// Handles all services and business rules related to <see cref="SQLUserProjectController"/>.
|
||||
/// Handles all services and business rules related to <see cref="SqlSampleController"/>.
|
||||
/// </summary>
|
||||
public SQLUserProjectController(
|
||||
IComponentHandler<GetUserProjectRequest> getUserProjectHandler,
|
||||
IComponentHandler<GetAllUserProjectsRequest> getAllUserProjectsHandler,
|
||||
IComponentHandler<CreateUserProjectRequest> createUserProjectHandler,
|
||||
IComponentHandler<UpdateUserProjectRequest> updateUserProjectHandler,
|
||||
IComponentHandler<DeleteUserProjectRequest> deleteUserProjectStatusHandler,
|
||||
public SqlSampleController(
|
||||
IComponentHandler<GetSqlSampleRequest> getSampleHandler,
|
||||
IComponentHandler<GetAllSqlSamplesRequest> getAllSamplesHandler,
|
||||
IComponentHandler<CreateSqlSampleRequest> createSampleHandler,
|
||||
IComponentHandler<UpdateSqlSampleRequest> updateSampleHandler,
|
||||
IComponentHandler<DeleteSqlSampleRequest> deleteSampleStatusHandler,
|
||||
ISQLPort port
|
||||
)
|
||||
{
|
||||
this.createUserProjectHandler = createUserProjectHandler;
|
||||
this.updateUserProjectHandler = updateUserProjectHandler;
|
||||
this.deleteUserProjectStatusHandler = deleteUserProjectStatusHandler;
|
||||
this.getAllUserProjectsHandler = getAllUserProjectsHandler;
|
||||
this.getUserProjectHandler = getUserProjectHandler;
|
||||
this.createSampleHandler = createSampleHandler;
|
||||
this.updateSampleHandler = updateSampleHandler;
|
||||
this.deleteSampleStatusHandler = deleteSampleStatusHandler;
|
||||
this.getAllSamplesHandler = getAllSamplesHandler;
|
||||
this.getSampleHandler = getSampleHandler;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new UserProject.
|
||||
/// Creates a new Sample.
|
||||
/// </summary>
|
||||
[HttpPost("Create")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -53,14 +53,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> CreateUserProjectAsync([FromBody] CreateUserProjectRequest newUserProject, CancellationToken cancellationToken = default)
|
||||
public async Task<IActionResult> CreateSampleAsync([FromBody] CreateSqlSampleRequest newSample, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await createUserProjectHandler.ExecuteAsync(newUserProject, cancellationToken).ConfigureAwait(false);
|
||||
await createSampleHandler.ExecuteAsync(newSample, cancellationToken).ConfigureAwait(false);
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets all UserProjects.
|
||||
/// Gets all Samples.
|
||||
/// </summary>
|
||||
[HttpGet("GetAll")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -70,14 +70,14 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> GetAllUserProjectsAsync(CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> GetAllSamplesAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
await getAllUserProjectsHandler.ExecuteAsync(new GetAllUserProjectsRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
await getAllSamplesHandler.ExecuteAsync(new GetAllSqlSamplesRequest { }, cancellationToken).ConfigureAwait(false);
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UserProject by identifier.
|
||||
/// Gets the Sample by identifier.
|
||||
/// </summary>
|
||||
[HttpPost]
|
||||
[Route("GetById")]
|
||||
@ -88,17 +88,17 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetUserProjectById([FromBody] GetUserProjectRequest request, CancellationToken cancellationToken)
|
||||
public async Task<IActionResult> GetSampleById([FromBody] GetSqlSampleRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
|
||||
if (request.Id <= 0) { return BadRequest("Invalid Sample identifier"); }
|
||||
|
||||
await getUserProjectHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await getSampleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates a full UserProject by identifier.
|
||||
/// Updates a full Sample by identifier.
|
||||
/// </summary>
|
||||
[HttpPut("Update")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
@ -108,17 +108,17 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> UpdateUserProjectAsync([FromBody] UpdateUserProjectRequest request, CancellationToken cancellationToken = default)
|
||||
public async Task<IActionResult> UpdateSampleAsync([FromBody] UpdateSqlSampleRequest request, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
|
||||
if (request.Id <= 0) { return BadRequest("Invalid Sample identifier"); }
|
||||
|
||||
await updateUserProjectHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await updateSampleHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes a UserProject.
|
||||
/// Deletes a Sample.
|
||||
/// </summary>
|
||||
[HttpDelete]
|
||||
[Route("Delete")]
|
||||
@ -129,12 +129,12 @@ namespace Core.Cerberos.Service.API.Controllers
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)]
|
||||
[ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> DeleteUserProjectStatusAsync([FromBody] DeleteUserProjectRequest request,
|
||||
public async Task<IActionResult> DeleteSampleStatusAsync([FromBody] DeleteSqlSampleRequest request,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
if (request.Id <= 0) { return BadRequest("Invalid UserProject identifier"); }
|
||||
if (request.Id <= 0) { return BadRequest("Invalid Sample identifier"); }
|
||||
|
||||
await deleteUserProjectStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
await deleteSampleStatusHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return port.ViewModel;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
@ -11,7 +11,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Asp.Versioning.Mvc.ApiExplorer" Version="8.1.0" />
|
||||
<PackageReference Include="Core.Blueprint.Logging" Version="0.3.0-alpha0034" />
|
||||
<PackageReference Include="Core.Blueprint.Logging" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.1.0-preview" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||
|
||||
@ -1,19 +1,21 @@
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Input;
|
||||
using Core.Blueprint.Application.UsesCases.BlobStorage.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Input;
|
||||
using Core.Blueprint.Application.UsesCases.KeyVault.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Input;
|
||||
using Core.Blueprint.Application.UsesCases.Mongo.Ports;
|
||||
using Core.Blueprint.Application.UsesCases.MongoStorage.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.SQL;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Adapter;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Input;
|
||||
using Core.Blueprint.Application.UsesCases.SQL.Ports;
|
||||
using Core.Cerberos.Application.UseCases.Blueprints;
|
||||
using Core.Cerberos.Application.UseCases.Blueprints.Validator;
|
||||
using Core.Cerberos.Application.UseCases.KeyVault;
|
||||
using Core.Cerberos.Application.UseCases.KeyVault.Validator;
|
||||
using Core.Cerberos.Application.UseCases.Mongo.Validator;
|
||||
using Core.Cerberos.Application.UseCases.SQL.Validator;
|
||||
using Core.Cerberos.Application.UseCases.UserProjects;
|
||||
using FluentValidation;
|
||||
using Lib.Architecture.BuildingBlocks;
|
||||
|
||||
@ -26,45 +28,45 @@ namespace Core.Blueprint.Service.API.Extensions
|
||||
#region Mongo Services
|
||||
services.AddScoped<IMongoPort, MongoPort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateBlueprintValidator>();
|
||||
services.AddScoped<IValidator<CreateBlueprintRequest>, CreateBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateBlueprintRequest>, MongoHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<CreateSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<CreateMongoSampleRequest>, CreateMongoSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateMongoSampleRequest>, MongoHandler>();
|
||||
|
||||
services.AddScoped<IComponentHandler<GetAllBlueprintsRequest>, MongoHandler>();
|
||||
services.AddScoped<IComponentHandler<GetAllMongoSamplesRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetBlueprintValidator>();
|
||||
services.AddScoped<IValidator<GetBlueprintRequest>, GetBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<GetBlueprintRequest>, MongoHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<GetSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<GetMongoSampleRequest>, GetMongoSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<GetMongoSampleRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateBlueprintValidator>();
|
||||
services.AddScoped<IValidator<UpdateBlueprintRequest>, UpdateBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateBlueprintRequest>, MongoHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<UpdateMongoSampleRequest>, UpdateMongoSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateMongoSampleRequest>, MongoHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteBlueprintValidator>();
|
||||
services.AddScoped<IValidator<DeleteBlueprintRequest>, DeleteBlueprintValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteBlueprintRequest>, MongoHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<DeleteMongoSampleRequest>, DeleteMongoSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteMongoSampleRequest>, MongoHandler>();
|
||||
#endregion
|
||||
|
||||
#region SQL Services
|
||||
services.AddScoped<ISQLPort, SQLPort>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<CreateUserProjectValidator>();
|
||||
services.AddScoped<IValidator<CreateUserProjectRequest>, CreateUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateUserProjectRequest>, SQLHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<CreateSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<CreateSqlSampleRequest>, CreateSqlSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<CreateSqlSampleRequest>, SQLHandler>();
|
||||
|
||||
services.AddScoped<IComponentHandler<GetAllUserProjectsRequest>, SQLHandler>();
|
||||
services.AddScoped<IComponentHandler<GetAllSqlSamplesRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<GetUserProjectValidator>();
|
||||
services.AddScoped<IValidator<GetUserProjectRequest>, GetUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<GetUserProjectRequest>, SQLHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<GetSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<GetSqlSampleRequest>, GetSqlSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<GetSqlSampleRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateUserProjectValidator>();
|
||||
services.AddScoped<IValidator<UpdateUserProjectRequest>, UpdateUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateUserProjectRequest>, SQLHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<UpdateSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<UpdateSqlSampleRequest>, UpdateSqlSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<UpdateSqlSampleRequest>, SQLHandler>();
|
||||
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteUserProjectValidator>();
|
||||
services.AddScoped<IValidator<DeleteUserProjectRequest>, DeleteUserProjectValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteUserProjectRequest>, SQLHandler>();
|
||||
services.AddValidatorsFromAssemblyContaining<DeleteSqlSampleValidator>();
|
||||
services.AddScoped<IValidator<DeleteSqlSampleRequest>, DeleteSqlSampleValidator>();
|
||||
services.AddScoped<IComponentHandler<DeleteSqlSampleRequest>, SQLHandler>();
|
||||
#endregion
|
||||
|
||||
#region KeyVault Services
|
||||
|
||||
@ -10,21 +10,21 @@ using System.Text.Json.Serialization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
builder.Configuration.AddAzureAppConfiguration(options =>
|
||||
{
|
||||
var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value;
|
||||
//builder.Configuration.AddAzureAppConfiguration(options =>
|
||||
//{
|
||||
// var endpoint = builder.Configuration.GetSection("Endpoints:AppConfigurationURI").Value;
|
||||
|
||||
if (string.IsNullOrEmpty(endpoint))
|
||||
throw new ArgumentException("The app configuration is missing");
|
||||
// if (string.IsNullOrEmpty(endpoint))
|
||||
// throw new ArgumentException("The app configuration is missing");
|
||||
|
||||
options.Connect(new Uri(endpoint), new DefaultAzureCredential())
|
||||
.Select(KeyFilter.Any, "blueprint_service");
|
||||
// options.Connect(new Uri(endpoint), new DefaultAzureCredential())
|
||||
// .Select(KeyFilter.Any, "blueprint_service");
|
||||
|
||||
options.ConfigureKeyVault(keyVaultOptions =>
|
||||
{
|
||||
keyVaultOptions.SetCredential(new DefaultAzureCredential());
|
||||
});
|
||||
});
|
||||
// options.ConfigureKeyVault(keyVaultOptions =>
|
||||
// {
|
||||
// keyVaultOptions.SetCredential(new DefaultAzureCredential());
|
||||
// });
|
||||
//});
|
||||
|
||||
builder.Services.AddLogs(builder);
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Core.Blueprint.Service.External.Clients.Adapters
|
||||
{
|
||||
public class BlueprintAdapter
|
||||
public class MongoSampleAdapter
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Core.Blueprint.Service.External.Clients.Adapters
|
||||
{
|
||||
public class UserProjectAdapter
|
||||
public class SqlSampleAdapter
|
||||
{
|
||||
public string ProjectCode { get; set; } = null!;
|
||||
public string ProjectDescription { get; set; } = null!;
|
||||
@ -10,35 +10,35 @@ namespace Core.Blueprint.Service.External.Clients
|
||||
{
|
||||
public interface IBlueprintServiceClient
|
||||
{
|
||||
[Post("/v1/MongoBlueprint/Create")]
|
||||
Task<BlueprintAdapter> CreateBlueprintAsync([FromBody] BlueprintRequest newBlueprint, CancellationToken cancellationToken = default);
|
||||
[Post("/v1/MongoSample/Create")]
|
||||
Task<MongoSampleAdapter> CreateMongoSampleAsync([FromBody] MongoSampleRequest newSample, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/MongoBlueprint/GetAll")]
|
||||
Task<IEnumerable<BlueprintAdapter>> GetAllBlueprintsAsync(CancellationToken cancellationToken = default);
|
||||
[Get("/v1/MongoSample/GetAll")]
|
||||
Task<IEnumerable<MongoSampleAdapter>> GetAllMongoSamplesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/MongoBlueprint/{_id}/GetBy_Id")]
|
||||
Task<BlueprintAdapter> GetBlueprintByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
[Get("/v1/MongoSample/{_id}/GetBy_Id")]
|
||||
Task<MongoSampleAdapter> GetMongoSampleByIdAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/MongoBlueprint/{_id}/Update")]
|
||||
Task<BlueprintAdapter> UpdateBlueprintAsync([FromRoute] string _id, [FromBody] BlueprintAdapter entity, CancellationToken cancellationToken = default);
|
||||
[Put("/v1/MongoSample/{_id}/Update")]
|
||||
Task<MongoSampleAdapter> UpdateMongoSampleAsync([FromRoute] string _id, [FromBody] MongoSampleAdapter entity, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/MongoBlueprint/{_id}/Delete")]
|
||||
Task<BlueprintAdapter> DeleteBlueprintAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
[Delete("/v1/MongoSample/{_id}/Delete")]
|
||||
Task<MongoSampleAdapter> DeleteMongoSampleAsync([FromRoute] string _id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/UserProject/Create")]
|
||||
Task<UserProjectAdapter> CreateUserProjectAsync([FromBody] UserProjectRequest newUserProject, CancellationToken cancellationToken = default);
|
||||
[Post("/v1/SqlSample/Create")]
|
||||
Task<SqlSampleAdapter> CreateSqlSampleAsync([FromBody] SqlSampleRequest newSqlSample, CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/UserProject/GetAll")]
|
||||
Task<IEnumerable<UserProjectAdapter>> GetAllUserProjectsAsync(CancellationToken cancellationToken = default);
|
||||
[Get("/v1/SqlSample/GetAll")]
|
||||
Task<IEnumerable<SqlSampleAdapter>> GetAllSqlSamplesAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
[Get("/v1/UserProject/{id}/GetById")]
|
||||
Task<UserProjectAdapter> GetUserProjectByIdAsync([FromRoute] int id, CancellationToken cancellationToken = default);
|
||||
[Get("/v1/SqlSample/{id}/GetById")]
|
||||
Task<SqlSampleAdapter> GetSqlSampleByIdAsync([FromRoute] int id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Put("/v1/UserProject/{id}/Update")]
|
||||
Task<UserProjectAdapter> UpdateUserProjectAsync([FromRoute] int id, [FromBody] UserProjectAdapter entity, CancellationToken cancellationToken = default);
|
||||
[Put("/v1/SqlSample/{id}/Update")]
|
||||
Task<SqlSampleAdapter> UpdateSqlSampleAsync([FromRoute] int id, [FromBody] SqlSampleAdapter entity, CancellationToken cancellationToken = default);
|
||||
|
||||
[Delete("/v1/UserProject/{id}/Delete")]
|
||||
Task<UserProjectAdapter> DeleteUserProjectAsync([FromRoute] int id, CancellationToken cancellationToken = default);
|
||||
[Delete("/v1/SqlSample/{id}/Delete")]
|
||||
Task<SqlSampleAdapter> DeleteSqlSampleAsync([FromRoute] int id, CancellationToken cancellationToken = default);
|
||||
|
||||
[Post("/v1/KeyVault/CreateSecret")]
|
||||
Task<KeyVaultResponse> CreateSecretAsync([FromBody] KeyVaultRequest newKeyVault, CancellationToken cancellationToken = default);
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
namespace Core.Blueprint.Service.External.Clients.Requests
|
||||
{
|
||||
public class BlueprintRequest
|
||||
public class MongoSampleRequest
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
public string? Description { get; set; }
|
||||
@ -0,0 +1,8 @@
|
||||
namespace Core.Blueprint.Service.External.Clients.Requests
|
||||
{
|
||||
public class SqlSampleRequest
|
||||
{
|
||||
public string Name { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
namespace Core.Blueprint.Service.External.Clients.Requests
|
||||
{
|
||||
public class UserProjectRequest
|
||||
{
|
||||
public string ProjectCode { get; set; } = null!;
|
||||
public string ProjectDescription { get; set; } = null!;
|
||||
public string UserId { get; set; } = null!;
|
||||
}
|
||||
}
|
||||
@ -7,19 +7,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
|
||||
<PackageReference Include="Core.Blueprint.KeyVault" Version="0.3.0-alpha0037" />
|
||||
<PackageReference Include="Core.Blueprint.Storage" Version="0.3.0-alpha0049" />
|
||||
<PackageReference Include="Lib.Architecture.BuildingBlocks" Version="0.9.0-alpha0008" />
|
||||
<PackageReference Include="Core.Blueprint.KeyVault" Version="1.0.0" />
|
||||
<PackageReference Include="Core.Blueprint.Storage" Version="1.0.1" />
|
||||
<PackageReference Include="BuildingBlocks.Library" Version="1.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
|
||||
<PackageReference Include="Refit" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="LSA.Core.Adapters">
|
||||
<HintPath>..\..\Dependencies\LSA.Core.Adapters.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user