Compare commits
2 Commits
6826319089
...
cf957eb3e0
| Author | SHA1 | Date | |
|---|---|---|---|
| cf957eb3e0 | |||
| bed3202892 |
@@ -171,6 +171,15 @@ namespace Core.Inventory.BFF.API.Controllers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Changes the status of the Product.
|
/// Changes the status of the Product.
|
||||||
/// </summary>
|
/// </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]
|
[HttpPatch]
|
||||||
[Route("ChangeStatus")]
|
[Route("ChangeStatus")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
@@ -256,5 +265,43 @@ namespace Core.Inventory.BFF.API.Controllers
|
|||||||
throw;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -154,6 +154,9 @@ namespace Core.Inventory.External.Clients.Inventory
|
|||||||
[Delete("/api/v1/Product/RemoveTag")]
|
[Delete("/api/v1/Product/RemoveTag")]
|
||||||
Task<ApiResponse<ProductAdapter>> RemoveTagFromProductAsync([Header("TrackingId")][Body] RemoveTagFromProductRequest request, CancellationToken cancellationToken = default);
|
Task<ApiResponse<ProductAdapter>> RemoveTagFromProductAsync([Header("TrackingId")][Body] RemoveTagFromProductRequest request, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
|
[Delete("/api/v1/Product/Delete")]
|
||||||
|
Task<ApiResponse<ProductAdapter>> DeleteProductService([Header("TrackingId")][Body] DeleteProductRequest request, CancellationToken cancellationToken = default);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
|||||||
public string TenantId { get; set; } = null!;
|
public string TenantId { get; set; } = null!;
|
||||||
public string ProductName { get; set; } = null!;
|
public string ProductName { get; set; } = null!;
|
||||||
public string Description { get; set; } = null!;
|
public string Description { get; set; } = null!;
|
||||||
public string Status { get; set; } = null!;
|
public string ProductStatus { get; set; } = null!;
|
||||||
public List<string> TagIds { get; set; } = new List<string>();
|
public List<string> TagIds { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Lib.Architecture.BuildingBlocks;
|
||||||
|
|
||||||
|
namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
||||||
|
{
|
||||||
|
public class DeleteProductRequest : Notificator, ICommand
|
||||||
|
{
|
||||||
|
public string Id { get; set; } = null!;
|
||||||
|
|
||||||
|
public bool Validate()
|
||||||
|
{
|
||||||
|
return Id != null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,7 +8,7 @@ namespace Core.Inventory.External.Clients.Inventory.Requests.Product
|
|||||||
public string TenantId { get; set; } = null!;
|
public string TenantId { get; set; } = null!;
|
||||||
public string ProductName { get; set; } = null!;
|
public string ProductName { get; set; } = null!;
|
||||||
public string Description { get; set; } = null!;
|
public string Description { get; set; } = null!;
|
||||||
public string Status { get; set; } = null!;
|
public string ProductStatus { get; set; } = null!;
|
||||||
public List<string> TagIds { get; set; } = new List<string>();
|
public List<string> TagIds { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Adapters.Lib" Version="1.0.11" />
|
<PackageReference Include="Adapters.Lib" Version="1.0.13" />
|
||||||
<PackageReference Include="BuildingBlocks.Library" Version="1.0.0" />
|
<PackageReference Include="BuildingBlocks.Library" Version="1.0.0" />
|
||||||
<PackageReference Include="Refit" Version="8.0.0" />
|
<PackageReference Include="Refit" Version="8.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
Reference in New Issue
Block a user