Compare commits
	
		
			2 Commits
		
	
	
		
			main
			...
			feature/re
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | b757f2a6c2 | ||
|   | 37db76d94a | 
| @@ -1,4 +1,4 @@ | ||||
| using Lib.Architecture.BuildingBlocks.Presentation.Adapters; | ||||
| using Lib.Architecture.BuildingBlocks; | ||||
| using Microsoft.AspNetCore.Mvc; | ||||
| using Newtonsoft.Json; | ||||
| using Refit; | ||||
|   | ||||
| @@ -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 | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Handles all requests for user project. | ||||
|     /// Handles all requests for blueprint. | ||||
|     /// </summary> | ||||
|     [ApiVersion("1.0")] | ||||
|     //[Route("api/v{version:apiVersion}/[controller]")] | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     public class SQLUserProjectController(IBlueprintServiceClient blueprintServiceClient, ILogger<SQLUserProjectController> logger) : BaseController(logger) | ||||
|     public class MongoSampleController(IBlueprintServiceClient blueprintServiceClient, ILogger<MongoSampleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Creates a new user project. | ||||
|         /// Creates a new MongoSample. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> CreateUserProjectService(CreateUserProjectRequest newUserProject, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Gets all user projects. | ||||
|         /// Gets all Mongo Samples. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> GetAllUserProjectsService(CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Gets the user project by identifier. | ||||
|         /// Gets the Mongo Sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> GetUserProjectByIdService(GetUserProjectRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Updates a full user project by identifier. | ||||
|         /// Updates a full Mongo Sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> UpdateUserProjectService(UpdateUserProjectRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Deletes the user project by identifier. | ||||
|         /// Deletes the Mongo Sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> DeleteUserProjectService(DeleteUserProjectRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| @@ -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 | ||||
| { | ||||
|     /// <summary> | ||||
|     /// Handles all requests for blueprint. | ||||
|     /// Handles all requests for sql sample. | ||||
|     /// </summary> | ||||
|     [ApiVersion("1.0")] | ||||
|     //[Route("api/v{version:apiVersion}/[controller]")] | ||||
|     [Consumes("application/json")] | ||||
|     [Produces("application/json")] | ||||
|     [ApiController] | ||||
|     public class MongoBlueprintController(IBlueprintServiceClient blueprintServiceClient, ILogger<MongoBlueprintController> logger) : BaseController(logger) | ||||
|     public class SqlSampleController(IBlueprintServiceClient blueprintServiceClient, ILogger<SqlSampleController> logger) : BaseController(logger) | ||||
|     { | ||||
|         /// <summary> | ||||
|         /// Creates a new blueprint. | ||||
|         /// Creates a new sql sample. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> CreateBlueprintService(CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Gets all blueprints. | ||||
|         /// Gets all sql samples. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> GetAllBlueprintsService(CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Gets the blueprint by identifier. | ||||
|         /// Gets the sql sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> GetBlueprintByIdService(GetBlueprintRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Updates a full blueprint by identifier. | ||||
|         /// Updates a full sql sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> UpdateBlueprintService(UpdateBlueprintRequest newBlueprint, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         /// <summary> | ||||
|         /// Deletes the blueprint by identifier. | ||||
|         /// Deletes the sql sample by identifier. | ||||
|         /// </summary> | ||||
|         [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<IActionResult> DeleteBlueprintService(DeleteBlueprintRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> 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; | ||||
|             } | ||||
|         } | ||||
| @@ -9,7 +9,7 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <PackageReference Include="Core.Blueprint.Logging" Version="0.3.0-alpha0034" /> | ||||
|     <PackageReference Include="Blueprint.Logging" Version="0.0.1" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.10" /> | ||||
|     <PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.0.0" /> | ||||
|   | ||||
| @@ -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; } | ||||
| @@ -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; } | ||||
| @@ -13,35 +13,35 @@ namespace Core.Blueprint.External.Clients.Blueprint | ||||
| { | ||||
|     public interface IBlueprintServiceClient | ||||
|     { | ||||
|         [Post("/v1/MongoBlueprint/Create")] | ||||
|         Task<ApiResponse<BlueprintAdapter>> CreateBlueprintService([Body] CreateBlueprintRequest newBlueprint, CancellationToken cancellationToken = default); | ||||
|         [Post("/v1/MongoSample/Create")] | ||||
|         Task<ApiResponse<MongoSampleAdapter>> CreateMongoSampleService([Body] CreateMongoSampleRequest newMongoSample, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Get("/v1/MongoBlueprint/GetAll")] | ||||
|         Task<ApiResponse<IEnumerable<BlueprintAdapter>>> GetAllBlueprintsService(CancellationToken cancellationToken = default); | ||||
|         [Get("/v1/MongoSample/GetAll")] | ||||
|         Task<ApiResponse<IEnumerable<MongoSampleAdapter>>> GetAllMongoSamplesService(CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/MongoBlueprint/GetById")] | ||||
|         Task<ApiResponse<BlueprintAdapter>> GetBlueprintByIdService([Body] GetBlueprintRequest request, CancellationToken cancellationToken = default); | ||||
|         [Post("/v1/MongoSample/GetById")] | ||||
|         Task<ApiResponse<MongoSampleAdapter>> GetMongoSampleByIdService([Body] GetMongoSampleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Put("/v1/MongoBlueprint/Update")] | ||||
|         Task<ApiResponse<BlueprintAdapter>> UpdateBlueprintService([Body] UpdateBlueprintRequest entity, CancellationToken cancellationToken = default); | ||||
|         [Put("/v1/MongoSample/Update")] | ||||
|         Task<ApiResponse<MongoSampleAdapter>> UpdateMongoSampleService([Body] UpdateMongoSampleRequest entity, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/MongoBlueprint/Delete")] | ||||
|         Task<ApiResponse<BlueprintAdapter>> DeleteBlueprintService([Body] DeleteBlueprintRequest request, CancellationToken cancellationToken = default); | ||||
|         [Delete("/v1/MongoSample/Delete")] | ||||
|         Task<ApiResponse<MongoSampleAdapter>> DeleteMongoSampleService([Body] DeleteMongoSampleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/SQLUserProject/Create")] | ||||
|         Task<ApiResponse<UserProjectAdapter>> CreateUserProjectService([Body] CreateUserProjectRequest newUserProject, CancellationToken cancellationToken = default); | ||||
|         [Post("/v1/SqlSample/Create")] | ||||
|         Task<ApiResponse<SqlSampleAdapter>> CreateSqlSampleService([Body] CreateSqlSampleRequest newSqlSample, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Get("/v1/SQLUserProject/GetAll")] | ||||
|         Task<ApiResponse<IEnumerable<UserProjectAdapter>>> GetAllUserProjectsService(CancellationToken cancellationToken = default); | ||||
|         [Get("/v1/SqlSample/GetAll")] | ||||
|         Task<ApiResponse<IEnumerable<SqlSampleAdapter>>> GetAllSqlSamplesService(CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/SQLUserProject/GetById")] | ||||
|         Task<ApiResponse<UserProjectAdapter>> GetUserProjectByIdService([Body] GetUserProjectRequest request, CancellationToken cancellationToken = default); | ||||
|         [Post("/v1/SqlSample/GetById")] | ||||
|         Task<ApiResponse<SqlSampleAdapter>> GetSqlSampleByIdService([Body] GetSqlSampleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Put("/v1/SQLUserProject/Update")] | ||||
|         Task<ApiResponse<UserProjectAdapter>> UpdateUserProjectService([Body] UpdateUserProjectRequest entity, CancellationToken cancellationToken = default); | ||||
|         [Put("/v1/SqlSample/Update")] | ||||
|         Task<ApiResponse<SqlSampleAdapter>> UpdateSqlSampleService([Body] UpdateSqlSampleRequest entity, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Delete("/v1/SQLUserProject/Delete")] | ||||
|         Task<ApiResponse<UserProjectAdapter>> DeleteUserProjectService([Body] DeleteUserProjectRequest request, CancellationToken cancellationToken = default); | ||||
|         [Delete("/v1/SqlSample/Delete")] | ||||
|         Task<ApiResponse<SqlSampleAdapter>> DeleteSqlSampleService([Body] DeleteSqlSampleRequest request, CancellationToken cancellationToken = default); | ||||
|  | ||||
|         [Post("/v1/KeyVault/CreateSecret")] | ||||
|         Task<ApiResponse<KeyVaultResponse>> CreateSecretService([Body] CreateSecretRequest newKeyVault, CancellationToken cancellationToken = default); | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo | ||||
| { | ||||
|     public class CreateBlueprintRequest | ||||
|     public class CreateMongoSampleRequest | ||||
|     { | ||||
|         public string Name { get; set; } = null!; | ||||
| 
 | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo | ||||
| { | ||||
|     public class DeleteBlueprintRequest | ||||
|     public class DeleteMongoSampleRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo | ||||
| { | ||||
|     public class GetAllBlueprintsRequest | ||||
|     public class GetAllMongoSamplesRequest | ||||
|     { | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.Mongo | ||||
| { | ||||
|     public class GetBlueprintRequest | ||||
|     public class GetMongoSampleRequest | ||||
|     { | ||||
|         public string _Id { get; set; } | ||||
|     } | ||||
| @@ -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; } | ||||
| @@ -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!; | ||||
|     } | ||||
| } | ||||
| @@ -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!; | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL | ||||
| { | ||||
|     public class DeleteUserProjectRequest | ||||
|     public class DeleteSqlSampleRequest | ||||
|     { | ||||
|         public int Id { get; set; } | ||||
|     } | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL | ||||
| { | ||||
|     public class GetAllUserProjectsRequest | ||||
|     public class GetAllSqlSamplesRequest | ||||
|     { | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| namespace Core.Blueprint.External.Clients.Blueprint.Requests.SQL | ||||
| { | ||||
|     public class GetUserProjectRequest | ||||
|     public class GetSqlSampleRequest | ||||
|     { | ||||
|         public int Id { get; set; } | ||||
|     } | ||||
| @@ -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; } | ||||
| @@ -7,11 +7,9 @@ | ||||
|   </PropertyGroup> | ||||
|  | ||||
|   <ItemGroup> | ||||
|     <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="Microsoft.AspNetCore.Http" Version="2.2.2" /> | ||||
|     <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" /> | ||||
|     <PackageReference Include="Blueprint.KeyVault" Version="0.0.1" /> | ||||
|     <PackageReference Include="Blueprint.Storage" Version="0.0.1" /> | ||||
|     <PackageReference Include="BuildingBlocks.Library" Version="0.0.1" /> | ||||
|     <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" /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user