Create general structures in Mongo and SQL
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user