Merge pull request 'feat: added endpoint DeleteProduct (BFF)' (#5) from feature/create-Product-and-ProductTag-CRUD into development
Reviewed-on: #5 Reviewed-by: Sergio Matías <sergio.matias@agilewebs.com> Reviewed-by: OscarMmtz <oscar.morales@agilewebs.com>
This commit is contained in:
		| @@ -171,6 +171,15 @@ namespace Core.Inventory.BFF.API.Controllers | ||||
|         /// <summary> | ||||
|         /// Changes the status of the Product. | ||||
|         /// </summary> | ||||
|         /// <param name="request">The request containing the product ID and new ProductStatus.</param> | ||||
|         /// <returns>The <see cref="ProductAdapter"/> updated entity.</returns> | ||||
|         /// <response code="200">The Product updates.</response> | ||||
|         /// <response code="204">The Product not found.</response> | ||||
|         /// <response code="400">The Product could not be updated.</response> | ||||
|         /// <response code="401">The Product could not be updated.</response> | ||||
|         /// <response code="412">The Product could not be updated.</response> | ||||
|         /// <response code="422">The Product could not be updated.</response> | ||||
|         /// <response code="500">The service internal error.</response> | ||||
|         [HttpPatch] | ||||
|         [Route("ChangeStatus")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
| @@ -256,5 +265,43 @@ namespace Core.Inventory.BFF.API.Controllers | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Deletes a Product by its identifier. | ||||
|         /// </summary> | ||||
|         /// <param name="request">The request containing the product ID to delete.</param> | ||||
|         /// <param name="cancellationToken">Cancellation token for the asynchronous operation.</param> | ||||
|         /// <returns>The <see cref="IActionResult"/> representing the result of the service call.</returns> | ||||
|         /// <response code="200">The Product deleted successfully.</response> | ||||
|         /// <response code="204">No content if the Product was not found.</response> | ||||
|         /// <response code="400">Bad request if the Product ID is missing or invalid.</response> | ||||
|         /// <response code="401">Unauthorized if the user is not authenticated.</response> | ||||
|         /// <response code="412">Precondition failed if the request does not meet expected conditions.</response> | ||||
|         /// <response code="422">Unprocessable entity if the request cannot be processed.</response> | ||||
|         /// <response code="500">Internal server error if an unexpected error occurs.</response> | ||||
|         [HttpDelete("Delete")] | ||||
|         [ProducesResponseType(StatusCodes.Status200OK)] | ||||
|         [ProducesResponseType(StatusCodes.Status204NoContent)] | ||||
|         [ProducesResponseType(StatusCodes.Status400BadRequest)] | ||||
|         [ProducesResponseType(StatusCodes.Status401Unauthorized)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status412PreconditionFailed)] | ||||
|         [ProducesResponseType(typeof(Notification), StatusCodes.Status422UnprocessableEntity)] | ||||
|         [ProducesResponseType(StatusCodes.Status500InternalServerError)] | ||||
|         public async Task<IActionResult> DeleteProductService([FromBody] DeleteProductRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 logger.LogInformation($"{nameof(DeleteProductService)} - Request received - Payload: {JsonSerializer.Serialize(request)}"); | ||||
|  | ||||
|                 if (string.IsNullOrEmpty(request.Id)) { return BadRequest("Invalid Product identifier"); } | ||||
|  | ||||
|                 return await Handle(() => inventoryServiceClient.DeleteProductService(request, cancellationToken)).ConfigureAwait(false); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             { | ||||
|                 logger.LogError($"{nameof(DeleteProductService)} - An Error Occurred- {ex.Message} - {ex.InnerException} - {ex.StackTrace} - with payload {JsonSerializer.Serialize(request)}"); | ||||
|                 throw; | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| }  | ||||
		Reference in New Issue
	
	Block a user