Added new endpoint for variants GetAll
This commit is contained in:
		| @@ -12,27 +12,36 @@ namespace Core.Inventory.Service.API.Controllers | ||||
|     [ApiController] | ||||
|     public class FurnitureVariantController( | ||||
|         IComponentHandler<GetFurnitureVariantByIdRequest> getByIdHandler, | ||||
|         IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> getAllHandler, | ||||
|         IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> getAllMyModelIdHandler, | ||||
|         IComponentHandler<CreateFurnitureVariantRequest> createHandler, | ||||
|         IComponentHandler<UpdateFurnitureVariantRequest> updateHandler, | ||||
|         IComponentHandler<ChangeFurnitureVariantStatusRequest> changeStatusHandler, | ||||
|         IComponentHandler<GetFurnitureVariantsByIdsRequest> getByIdsHandler, | ||||
|         IComponentHandler<GetAllFurnitureVariantRequest> getAllHandler, | ||||
|         IFurnitureVariantPort port) : ControllerBase | ||||
|     { | ||||
|         private readonly IComponentHandler<GetFurnitureVariantByIdRequest> _getByIdHandler = getByIdHandler; | ||||
|         private readonly IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> _getAllHandler = getAllHandler; | ||||
|         private readonly IComponentHandler<GetAllFurnitureVariantsByModelIdRequest> _getAllByModelIdHandler = getAllMyModelIdHandler; | ||||
|         private readonly IComponentHandler<CreateFurnitureVariantRequest> _createHandler = createHandler; | ||||
|         private readonly IComponentHandler<UpdateFurnitureVariantRequest> _updateHandler = updateHandler; | ||||
|         private readonly IComponentHandler<ChangeFurnitureVariantStatusRequest> _changeStatusHandler = changeStatusHandler; | ||||
|         private readonly IComponentHandler<GetFurnitureVariantsByIdsRequest> _getByIdsHandler = getByIdsHandler; | ||||
|         private readonly IComponentHandler<GetAllFurnitureVariantRequest> _getAllHandler = getAllHandler; | ||||
|         private readonly IFurnitureVariantPort _port = port; | ||||
|  | ||||
|         [HttpGet("GetAll")] | ||||
|         public async Task<IActionResult> GetAllAsync(CancellationToken cancellationToken) | ||||
|         { | ||||
|             await _getAllHandler.ExecuteAsync(new GetAllFurnitureVariantRequest { }, cancellationToken).ConfigureAwait(false); | ||||
|             return _port.ViewModel; | ||||
|         } | ||||
|  | ||||
|         [HttpPost("GetAllByModelId")] | ||||
|         public async Task<IActionResult> GetAllAsync([FromBody] GetAllFurnitureVariantsByModelIdRequest request, CancellationToken cancellationToken) | ||||
|         public async Task<IActionResult> GetAllByModelIdAsync([FromBody] GetAllFurnitureVariantsByModelIdRequest request, CancellationToken cancellationToken) | ||||
|         { | ||||
|             if (string.IsNullOrEmpty(request?.ModelId)) return BadRequest("Model ID is required"); | ||||
|  | ||||
|             await _getAllHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||
|             await _getAllByModelIdHandler.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); | ||||
|             return _port.ViewModel; | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user