public async Task <IActionResult> RemoveOrderItem(Guid orderId, Guid productId) { var command = new RemoveOrderItemCommand(CustomerId, orderId, productId); await _mediatrHandler.SendCommand(command); if (IsOperationValid()) { return(RedirectToAction("Index")); } var shoppingCart = await _orderQueries.GetCustomerShoppingCart(CustomerId); return(View("Index", shoppingCart)); }
public async Task <IActionResult> RemoveItem(Guid id) { var product = await _productAppService.GetById(id); if (product == null) { return(BadRequest()); } var command = new RemoveOrderItemCommand(ClientId, id); await _mediatrHandler.SendCommand(command); if (ValidOperation()) { return(RedirectToAction("Index")); } return(View("Index", await _orderQueries.GetCartByClient(ClientId))); }
public async Task <JsonResult> RemoveOrderItem(RemoveOrderItemCommand removeOrder) { return(new JsonResult(await Mediator.Send(removeOrder))); }