From b757f2a6c2b46a232ef3ac41b6a81baea5d798b0 Mon Sep 17 00:00:00 2001 From: Sergio Matias Urquin Date: Sun, 18 May 2025 18:16:12 -0600 Subject: [PATCH] Add samples in mongo and sql layer --- ...Controller.cs => MongoSampleController.cs} | 81 +++++++++---------- ...ntController.cs => SqlSampleController.cs} | 79 +++++++++--------- ...eprintAdapter.cs => MongoSampleAdapter.cs} | 2 +- ...rProjectAdapter.cs => SqlSampleAdapter.cs} | 7 +- .../Blueprint/IBlueprintServiceClient.cs | 40 ++++----- ...Request.cs => CreateMongoSampleRequest.cs} | 2 +- ...Request.cs => DeleteMongoSampleRequest.cs} | 2 +- ...equest.cs => GetAllMongoSamplesRequest.cs} | 2 +- ...intRequest.cs => GetMongoSampleRequest.cs} | 2 +- ...Request.cs => UpdateMongoSampleRequest.cs} | 2 +- .../Requests/SQL/CreateSqlSampleRequest.cs | 8 ++ .../Requests/SQL/CreateUserProjectRequest.cs | 9 --- ...ctRequest.cs => DeleteSqlSampleRequest.cs} | 2 +- ...sRequest.cs => GetAllSqlSamplesRequest.cs} | 2 +- ...ojectRequest.cs => GetSqlSampleRequest.cs} | 2 +- ...ctRequest.cs => UpdateSqlSampleRequest.cs} | 7 +- 16 files changed, 122 insertions(+), 127 deletions(-) rename Core.Blueprint.API/Controllers/{SQLUserProjectController.cs => MongoSampleController.cs} (55%) rename Core.Blueprint.API/Controllers/{MongoBlueprintController.cs => SqlSampleController.cs} (60%) rename Core.Blueprint.External/Clients/Blueprint/Adapters/{BlueprintAdapter.cs => MongoSampleAdapter.cs} (94%) rename Core.Blueprint.External/Clients/Blueprint/Adapters/{UserProjectAdapter.cs => SqlSampleAdapter.cs} (68%) rename Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/{CreateBlueprintRequest.cs => CreateMongoSampleRequest.cs} (81%) rename Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/{DeleteBlueprintRequest.cs => DeleteMongoSampleRequest.cs} (75%) rename Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/{GetAllBlueprintsRequest.cs => GetAllMongoSamplesRequest.cs} (66%) rename Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/{GetBlueprintRequest.cs => GetMongoSampleRequest.cs} (76%) rename Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/{UpdateBlueprintRequest.cs => UpdateMongoSampleRequest.cs} (92%) create mode 100644 Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateSqlSampleRequest.cs delete mode 100644 Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateUserProjectRequest.cs rename Core.Blueprint.External/Clients/Blueprint/Requests/SQL/{DeleteUserProjectRequest.cs => DeleteSqlSampleRequest.cs} (74%) rename Core.Blueprint.External/Clients/Blueprint/Requests/SQL/{GetAllUserProjectsRequest.cs => GetAllSqlSamplesRequest.cs} (66%) rename Core.Blueprint.External/Clients/Blueprint/Requests/SQL/{GetUserProjectRequest.cs => GetSqlSampleRequest.cs} (75%) rename Core.Blueprint.External/Clients/Blueprint/Requests/SQL/{UpdateUserProjectRequest.cs => UpdateSqlSampleRequest.cs} (65%) diff --git a/Core.Blueprint.API/Controllers/SQLUserProjectController.cs b/Core.Blueprint.API/Controllers/MongoSampleController.cs similarity index 55% rename from Core.Blueprint.API/Controllers/SQLUserProjectController.cs rename to Core.Blueprint.API/Controllers/MongoSampleController.cs index 1279be6..ff5a073 100644 --- a/Core.Blueprint.API/Controllers/SQLUserProjectController.cs +++ b/Core.Blueprint.API/Controllers/MongoSampleController.cs @@ -1,24 +1,23 @@ -using Core.Blueprint.API.Controllers; -using Core.Blueprint.External.Clients.Blueprint; -using Core.Blueprint.External.Clients.Blueprint.Requests.SQL; +using Core.Blueprint.External.Clients.Blueprint; +using Core.Blueprint.External.Clients.Blueprint.Requests.Mongo; using Lib.Architecture.BuildingBlocks; using Microsoft.AspNetCore.Mvc; using System.Text.Json; -namespace Core.UserProject.API.Controllers +namespace Core.Blueprint.API.Controllers { /// - /// Handles all requests for user project. + /// Handles all requests for blueprint. /// [ApiVersion("1.0")] //[Route("api/v{version:apiVersion}/[controller]")] [Consumes("application/json")] [Produces("application/json")] [ApiController] - public class SQLUserProjectController(IBlueprintServiceClient blueprintServiceClient, ILogger logger) : BaseController(logger) + public class MongoSampleController(IBlueprintServiceClient blueprintServiceClient, ILogger logger) : BaseController(logger) { /// - /// Creates a new user project. + /// Creates a new MongoSample. /// [HttpPost("Create")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -27,31 +26,29 @@ namespace Core.UserProject.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task CreateUserProjectService(CreateUserProjectRequest newUserProject, CancellationToken cancellationToken) + public async Task CreateMongoSampleService(CreateMongoSampleRequest sample, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(CreateUserProjectService)} - Request received - Payload: {JsonSerializer.Serialize(newUserProject)}"); + logger.LogInformation($"{nameof(CreateMongoSampleService)} - Request received - Payload: {JsonSerializer.Serialize(sample)}"); - if (newUserProject == null) return BadRequest("Invalid user project object"); + if (sample == null) return BadRequest("Invalid sample object"); - if (string.IsNullOrEmpty(newUserProject.ProjectCode)) return BadRequest("Invalid project code"); + if (string.IsNullOrEmpty(sample.Name)) return BadRequest("Invalid sample name"); - if (string.IsNullOrEmpty(newUserProject.ProjectDescription)) return BadRequest("Invalid project description"); + if (string.IsNullOrEmpty(sample.Description)) return BadRequest("Invalid sample description"); - if (string.IsNullOrEmpty(newUserProject.UserId)) return BadRequest("Invalid user identifier"); - - return await Handle(() => blueprintServiceClient.CreateUserProjectService(newUserProject, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.CreateMongoSampleService(sample, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(CreateUserProjectService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newUserProject)}"); + logger.LogError($"{nameof(CreateMongoSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(sample)}"); throw; } } /// - /// Gets all user projects. + /// Gets all Mongo Samples. /// [HttpGet("GetAll")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -60,23 +57,23 @@ namespace Core.UserProject.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task GetAllUserProjectsService(CancellationToken cancellationToken) + public async Task GetAllMongoSamplesService(CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(GetAllUserProjectsService)} - Request received - Payload: "); + logger.LogInformation($"{nameof(GetAllMongoSamplesService)} - Request received - Payload: "); - return await Handle(() => blueprintServiceClient.GetAllUserProjectsService(cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.GetAllMongoSamplesService(cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(GetAllUserProjectsService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); + logger.LogError($"{nameof(GetAllMongoSamplesService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); throw; } } /// - /// Gets the user project by identifier. + /// Gets the Mongo Sample by identifier. /// [HttpPost("GetById")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -85,25 +82,25 @@ namespace Core.UserProject.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task GetUserProjectByIdService(GetUserProjectRequest request, CancellationToken cancellationToken) + public async Task GetMongoSampleByIdService(GetMongoSampleRequest request, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(GetUserProjectByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); + logger.LogInformation($"{nameof(GetMongoSampleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); - if (request.Id <= 0) return BadRequest("Invalid user project identifier"); + if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid MongoSample identifier"); - return await Handle(() => blueprintServiceClient.GetUserProjectByIdService(request, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.GetMongoSampleByIdService(request, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(GetUserProjectByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); + logger.LogError($"{nameof(GetMongoSampleByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); throw; } } /// - /// Updates a full user project by identifier. + /// Updates a full Mongo Sample by identifier. /// [HttpPut("Update")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -112,31 +109,29 @@ namespace Core.UserProject.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task UpdateUserProjectService(UpdateUserProjectRequest request, CancellationToken cancellationToken) + public async Task UpdateMongoSampleService(UpdateMongoSampleRequest newSample, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(UpdateUserProjectService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); + logger.LogInformation($"{nameof(UpdateMongoSampleService)} - Request received - Payload: {JsonSerializer.Serialize(newSample)}"); - if (request == null) return BadRequest("Invalid user project object"); + if (newSample == null) return BadRequest("Invalid sample object"); - if (string.IsNullOrEmpty(request.ProjectCode)) return BadRequest("Invalid user project code"); + if (string.IsNullOrEmpty(newSample.Name)) return BadRequest("Invalid sample name"); - if (string.IsNullOrEmpty(request.ProjectDescription)) return BadRequest("Invalid user project description"); + if (string.IsNullOrEmpty(newSample.Description)) return BadRequest("Invalid sample description"); - if (string.IsNullOrEmpty(request.UserId)) return BadRequest("Invalid user identifier"); - - return await Handle(() => blueprintServiceClient.UpdateUserProjectService(request, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.UpdateMongoSampleService(newSample, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(UpdateUserProjectService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); + logger.LogError($"{nameof(UpdateMongoSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newSample)}"); throw; } } /// - /// Deletes the user project by identifier. + /// Deletes the Mongo Sample by identifier. /// [HttpPost("Delete")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -145,19 +140,19 @@ namespace Core.UserProject.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task DeleteUserProjectService(DeleteUserProjectRequest request, CancellationToken cancellationToken) + public async Task DeleteMongoSampleService(DeleteMongoSampleRequest request, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(DeleteUserProjectService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); + logger.LogInformation($"{nameof(DeleteMongoSampleService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); - if (request.Id <= 0) return BadRequest("Invalid user project identifier"); + if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid sample identifier"); - return await Handle(() => blueprintServiceClient.DeleteUserProjectService(request, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.DeleteMongoSampleService(request, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(DeleteUserProjectService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); + logger.LogError($"{nameof(DeleteMongoSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); throw; } } diff --git a/Core.Blueprint.API/Controllers/MongoBlueprintController.cs b/Core.Blueprint.API/Controllers/SqlSampleController.cs similarity index 60% rename from Core.Blueprint.API/Controllers/MongoBlueprintController.cs rename to Core.Blueprint.API/Controllers/SqlSampleController.cs index c952528..a9b3082 100644 --- a/Core.Blueprint.API/Controllers/MongoBlueprintController.cs +++ b/Core.Blueprint.API/Controllers/SqlSampleController.cs @@ -1,23 +1,24 @@ -using Core.Blueprint.External.Clients.Blueprint; -using Core.Blueprint.External.Clients.Blueprint.Requests.Mongo; +using Core.Blueprint.API.Controllers; +using Core.Blueprint.External.Clients.Blueprint; +using Core.Blueprint.External.Clients.Blueprint.Requests.SQL; using Lib.Architecture.BuildingBlocks; using Microsoft.AspNetCore.Mvc; using System.Text.Json; -namespace Core.Blueprint.API.Controllers +namespace Core.SqlSample.API.Controllers { /// - /// Handles all requests for blueprint. + /// Handles all requests for sql sample. /// [ApiVersion("1.0")] //[Route("api/v{version:apiVersion}/[controller]")] [Consumes("application/json")] [Produces("application/json")] [ApiController] - public class MongoBlueprintController(IBlueprintServiceClient blueprintServiceClient, ILogger logger) : BaseController(logger) + public class SqlSampleController(IBlueprintServiceClient blueprintServiceClient, ILogger logger) : BaseController(logger) { /// - /// Creates a new blueprint. + /// Creates a new sql sample. /// [HttpPost("Create")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -26,29 +27,30 @@ namespace Core.Blueprint.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task CreateBlueprintService(CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken) + public async Task CreateSqlSampleService(CreateSqlSampleRequest sample, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(CreateBlueprintService)} - Request received - Payload: {JsonSerializer.Serialize(newBlueprint)}"); + logger.LogInformation($"{nameof(CreateSqlSampleService)} - Request received - Payload: {JsonSerializer.Serialize(sample)}"); - if (newBlueprint == null) return BadRequest("Invalid blueprint object"); + if (sample == null) return BadRequest("Invalid sql sample object"); - if (string.IsNullOrEmpty(newBlueprint.Name)) return BadRequest("Invalid blueprint name"); + if (string.IsNullOrEmpty(sample.Name)) return BadRequest("Invalid sample name"); - if (string.IsNullOrEmpty(newBlueprint.Description)) return BadRequest("Invalid blueprint description"); + if (string.IsNullOrEmpty(sample.Description)) return BadRequest("Invalid sample description"); - return await Handle(() => blueprintServiceClient.CreateBlueprintService(newBlueprint, cancellationToken)).ConfigureAwait(false); + + return await Handle(() => blueprintServiceClient.CreateSqlSampleService(sample, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(CreateBlueprintService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newBlueprint)}"); + logger.LogError($"{nameof(CreateSqlSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(sample)}"); throw; } } /// - /// Gets all blueprints. + /// Gets all sql samples. /// [HttpGet("GetAll")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -57,23 +59,23 @@ namespace Core.Blueprint.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task GetAllBlueprintsService(CancellationToken cancellationToken) + public async Task GetAllSqlSamplesService(CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(GetAllBlueprintsService)} - Request received - Payload: "); + logger.LogInformation($"{nameof(GetAllSqlSamplesService)} - Request received - Payload: "); - return await Handle(() => blueprintServiceClient.GetAllBlueprintsService(cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.GetAllSqlSamplesService(cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(GetAllBlueprintsService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); + logger.LogError($"{nameof(GetAllSqlSamplesService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload"); throw; } } /// - /// Gets the blueprint by identifier. + /// Gets the sql sample by identifier. /// [HttpPost("GetById")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -82,25 +84,25 @@ namespace Core.Blueprint.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task GetBlueprintByIdService(GetBlueprintRequest request, CancellationToken cancellationToken) + public async Task GetSqlSampleByIdService(GetSqlSampleRequest request, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(GetBlueprintByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); + logger.LogInformation($"{nameof(GetSqlSampleByIdService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); - if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid blueprint identifier"); + if (request.Id <= 0) return BadRequest("Invalid sql sample identifier"); - return await Handle(() => blueprintServiceClient.GetBlueprintByIdService(request, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.GetSqlSampleByIdService(request, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(GetBlueprintByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); + logger.LogError($"{nameof(GetSqlSampleByIdService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); throw; } } /// - /// Updates a full blueprint by identifier. + /// Updates a full sql sample by identifier. /// [HttpPut("Update")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -109,29 +111,30 @@ namespace Core.Blueprint.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task UpdateBlueprintService(UpdateBlueprintRequest newBlueprint, CancellationToken cancellationToken) + public async Task UpdateSqlSampleService(UpdateSqlSampleRequest request, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(UpdateBlueprintService)} - Request received - Payload: {JsonSerializer.Serialize(newBlueprint)}"); + logger.LogInformation($"{nameof(UpdateSqlSampleService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); - if (newBlueprint == null) return BadRequest("Invalid blueprint object"); + if (request == null) return BadRequest("Invalid sql sample object"); - if (string.IsNullOrEmpty(newBlueprint.Name)) return BadRequest("Invalid blueprint name"); + if (string.IsNullOrEmpty(request.Name)) return BadRequest("Invalid sql sample name"); - if (string.IsNullOrEmpty(newBlueprint.Description)) return BadRequest("Invalid blueprint description"); + if (string.IsNullOrEmpty(request.Description)) return BadRequest("Invalid sql sample description"); - return await Handle(() => blueprintServiceClient.UpdateBlueprintService(newBlueprint, cancellationToken)).ConfigureAwait(false); + + return await Handle(() => blueprintServiceClient.UpdateSqlSampleService(request, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(UpdateBlueprintService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(newBlueprint)}"); + logger.LogError($"{nameof(UpdateSqlSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); throw; } } /// - /// Deletes the blueprint by identifier. + /// Deletes the sql sample by identifier. /// [HttpPost("Delete")] [ProducesResponseType(StatusCodes.Status200OK)] @@ -140,19 +143,19 @@ namespace Core.Blueprint.API.Controllers [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] - public async Task DeleteBlueprintService(DeleteBlueprintRequest request, CancellationToken cancellationToken) + public async Task DeleteSqlSampleService(DeleteSqlSampleRequest request, CancellationToken cancellationToken) { try { - logger.LogInformation($"{nameof(DeleteBlueprintService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); + logger.LogInformation($"{nameof(DeleteSqlSampleService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); - if (string.IsNullOrEmpty(request._Id)) return BadRequest("Invalid blueprint identifier"); + if (request.Id <= 0) return BadRequest("Invalid sql sample identifier"); - return await Handle(() => blueprintServiceClient.DeleteBlueprintService(request, cancellationToken)).ConfigureAwait(false); + return await Handle(() => blueprintServiceClient.DeleteSqlSampleService(request, cancellationToken)).ConfigureAwait(false); } catch (Exception ex) { - logger.LogError($"{nameof(DeleteBlueprintService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); + logger.LogError($"{nameof(DeleteSqlSampleService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); throw; } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Adapters/BlueprintAdapter.cs b/Core.Blueprint.External/Clients/Blueprint/Adapters/MongoSampleAdapter.cs similarity index 94% rename from Core.Blueprint.External/Clients/Blueprint/Adapters/BlueprintAdapter.cs rename to Core.Blueprint.External/Clients/Blueprint/Adapters/MongoSampleAdapter.cs index 77e35c8..920c686 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Adapters/BlueprintAdapter.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Adapters/MongoSampleAdapter.cs @@ -2,7 +2,7 @@ namespace Core.Blueprint.External.Clients.Blueprint.Adapters { - public class BlueprintAdapter + public class MongoSampleAdapter { public string Name { get; set; } = null!; public string? Description { get; set; } diff --git a/Core.Blueprint.External/Clients/Blueprint/Adapters/UserProjectAdapter.cs b/Core.Blueprint.External/Clients/Blueprint/Adapters/SqlSampleAdapter.cs similarity index 68% rename from Core.Blueprint.External/Clients/Blueprint/Adapters/UserProjectAdapter.cs rename to Core.Blueprint.External/Clients/Blueprint/Adapters/SqlSampleAdapter.cs index 08ac0ed..40827ad 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Adapters/UserProjectAdapter.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Adapters/SqlSampleAdapter.cs @@ -2,11 +2,10 @@ namespace Core.Blueprint.External.Clients.Blueprint.Adapters { - public class UserProjectAdapter + public class SqlSampleAdapter { - 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; } diff --git a/Core.Blueprint.External/Clients/Blueprint/IBlueprintServiceClient.cs b/Core.Blueprint.External/Clients/Blueprint/IBlueprintServiceClient.cs index 65ce714..cf150f6 100644 --- a/Core.Blueprint.External/Clients/Blueprint/IBlueprintServiceClient.cs +++ b/Core.Blueprint.External/Clients/Blueprint/IBlueprintServiceClient.cs @@ -13,35 +13,35 @@ namespace Core.Blueprint.External.Clients.Blueprint { public interface IBlueprintServiceClient { - [Post("/v1/MongoBlueprint/Create")] - Task> CreateBlueprintService([Body] CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken = default); + [Post("/v1/MongoSample/Create")] + Task> CreateMongoSampleService([Body] CreateMongoSampleRequest newMongoSample, CancellationToken cancellationToken = default); - [Get("/v1/MongoBlueprint/GetAll")] - Task>> GetAllBlueprintsService(CancellationToken cancellationToken = default); + [Get("/v1/MongoSample/GetAll")] + Task>> GetAllMongoSamplesService(CancellationToken cancellationToken = default); - [Post("/v1/MongoBlueprint/GetById")] - Task> GetBlueprintByIdService([Body] GetBlueprintRequest request, CancellationToken cancellationToken = default); + [Post("/v1/MongoSample/GetById")] + Task> GetMongoSampleByIdService([Body] GetMongoSampleRequest request, CancellationToken cancellationToken = default); - [Put("/v1/MongoBlueprint/Update")] - Task> UpdateBlueprintService([Body] UpdateBlueprintRequest entity, CancellationToken cancellationToken = default); + [Put("/v1/MongoSample/Update")] + Task> UpdateMongoSampleService([Body] UpdateMongoSampleRequest entity, CancellationToken cancellationToken = default); - [Delete("/v1/MongoBlueprint/Delete")] - Task> DeleteBlueprintService([Body] DeleteBlueprintRequest request, CancellationToken cancellationToken = default); + [Delete("/v1/MongoSample/Delete")] + Task> DeleteMongoSampleService([Body] DeleteMongoSampleRequest request, CancellationToken cancellationToken = default); - [Post("/v1/SQLUserProject/Create")] - Task> CreateUserProjectService([Body] CreateUserProjectRequest newUserProject, CancellationToken cancellationToken = default); + [Post("/v1/SqlSample/Create")] + Task> CreateSqlSampleService([Body] CreateSqlSampleRequest newSqlSample, CancellationToken cancellationToken = default); - [Get("/v1/SQLUserProject/GetAll")] - Task>> GetAllUserProjectsService(CancellationToken cancellationToken = default); + [Get("/v1/SqlSample/GetAll")] + Task>> GetAllSqlSamplesService(CancellationToken cancellationToken = default); - [Post("/v1/SQLUserProject/GetById")] - Task> GetUserProjectByIdService([Body] GetUserProjectRequest request, CancellationToken cancellationToken = default); + [Post("/v1/SqlSample/GetById")] + Task> GetSqlSampleByIdService([Body] GetSqlSampleRequest request, CancellationToken cancellationToken = default); - [Put("/v1/SQLUserProject/Update")] - Task> UpdateUserProjectService([Body] UpdateUserProjectRequest entity, CancellationToken cancellationToken = default); + [Put("/v1/SqlSample/Update")] + Task> UpdateSqlSampleService([Body] UpdateSqlSampleRequest entity, CancellationToken cancellationToken = default); - [Delete("/v1/SQLUserProject/Delete")] - Task> DeleteUserProjectService([Body] DeleteUserProjectRequest request, CancellationToken cancellationToken = default); + [Delete("/v1/SqlSample/Delete")] + Task> DeleteSqlSampleService([Body] DeleteSqlSampleRequest request, CancellationToken cancellationToken = default); [Post("/v1/KeyVault/CreateSecret")] Task> CreateSecretService([Body] CreateSecretRequest newKeyVault, CancellationToken cancellationToken = default); diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateBlueprintRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateMongoSampleRequest.cs similarity index 81% rename from Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateBlueprintRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateMongoSampleRequest.cs index c5ccb82..e0ca4d7 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateBlueprintRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/CreateMongoSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo { - public class CreateBlueprintRequest + public class CreateMongoSampleRequest { public string Name { get; set; } = null!; diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteBlueprintRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteMongoSampleRequest.cs similarity index 75% rename from Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteBlueprintRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteMongoSampleRequest.cs index c1a6b7e..23104d1 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteBlueprintRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/DeleteMongoSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo { - public class DeleteBlueprintRequest + public class DeleteMongoSampleRequest { public string _Id { get; set; } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllBlueprintsRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllMongoSamplesRequest.cs similarity index 66% rename from Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllBlueprintsRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllMongoSamplesRequest.cs index 7a302ee..910d2c9 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllBlueprintsRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetAllMongoSamplesRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo { - public class GetAllBlueprintsRequest + public class GetAllMongoSamplesRequest { } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetBlueprintRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetMongoSampleRequest.cs similarity index 76% rename from Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetBlueprintRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetMongoSampleRequest.cs index 5197677..8eca2ee 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetBlueprintRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/GetMongoSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo { - public class GetBlueprintRequest + public class GetMongoSampleRequest { public string _Id { get; set; } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateBlueprintRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateMongoSampleRequest.cs similarity index 92% rename from Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateBlueprintRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateMongoSampleRequest.cs index 8cd933a..bc37114 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateBlueprintRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/Mongo/UpdateMongoSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo { - public class UpdateBlueprintRequest + public class UpdateMongoSampleRequest { public string Name { get; set; } = null!; public string? Description { get; set; } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateSqlSampleRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateSqlSampleRequest.cs new file mode 100644 index 0000000..94299a3 --- /dev/null +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateSqlSampleRequest.cs @@ -0,0 +1,8 @@ +namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL +{ + public class CreateSqlSampleRequest + { + public string Name { get; set; } = null!; + public string Description { get; set; } = null!; + } +} diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateUserProjectRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateUserProjectRequest.cs deleted file mode 100644 index 15d6f57..0000000 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/CreateUserProjectRequest.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL -{ - public class CreateUserProjectRequest - { - public string ProjectCode { get; set; } = null!; - public string ProjectDescription { get; set; } = null!; - public string UserId { get; set; } = null!; - } -} diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteUserProjectRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteSqlSampleRequest.cs similarity index 74% rename from Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteUserProjectRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteSqlSampleRequest.cs index e673b26..45a0f9f 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteUserProjectRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/DeleteSqlSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL { - public class DeleteUserProjectRequest + public class DeleteSqlSampleRequest { public int Id { get; set; } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllUserProjectsRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllSqlSamplesRequest.cs similarity index 66% rename from Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllUserProjectsRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllSqlSamplesRequest.cs index cdb3c49..403c348 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllUserProjectsRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetAllSqlSamplesRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL { - public class GetAllUserProjectsRequest + public class GetAllSqlSamplesRequest { } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetUserProjectRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetSqlSampleRequest.cs similarity index 75% rename from Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetUserProjectRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetSqlSampleRequest.cs index c5f0d2e..b64585f 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetUserProjectRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/GetSqlSampleRequest.cs @@ -1,6 +1,6 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL { - public class GetUserProjectRequest + public class GetSqlSampleRequest { public int Id { get; set; } } diff --git a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateUserProjectRequest.cs b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateSqlSampleRequest.cs similarity index 65% rename from Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateUserProjectRequest.cs rename to Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateSqlSampleRequest.cs index 041694c..3c59c15 100644 --- a/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateUserProjectRequest.cs +++ b/Core.Blueprint.External/Clients/Blueprint/Requests/SQL/UpdateSqlSampleRequest.cs @@ -1,10 +1,9 @@ namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL { - public class UpdateUserProjectRequest + public class UpdateSqlSampleRequest { - 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; }