public async Task ChangeOrderItemQuantityAsync(int orderId, int productId, ChangeOrderItemQuantityDto model) { var orderItem = await _context.OrderItems .FirstOrDefaultAsync(i => i.OrderId == orderId && i.ProductId == productId); if (orderItem == null) { throw new OrderItemNotFoundException(); } orderItem.Quantity = model.Quantity; await _context.SaveChangesAsync(); }
public async Task <ActionResult <OrderDto> > ChangeOrderItemQuantity([FromRoute] int orderId, [FromRoute] int productId, [FromBody] ChangeOrderItemQuantityDto model) { try { await _orderService.ChangeOrderItemQuantityAsync(orderId, productId, model); return(NoContent()); } catch (OrderItemNotFoundException) { return(NotFound()); } catch (Exception) { return(UnprocessableEntity()); } }