public async Task ModifyOrderItem(int orderId, int itemId, OrderItemModModel model) { if (model.Quantity < 1) { throw new RestaurantBadRequestException("A mennyiségnek pozitív számnak kell lennie!"); } var orderItem = await DbContext.OrderItems .Include(oi => oi.Order) .ThenInclude(o => o.OrderSession) .Where(oi => oi.Id == itemId && oi.OrderId == orderId && oi.Order.Status == OrderStatus.Ordering && oi.Order.OrderSession.Status == OrderSessionStatus.Active) .SingleOrDefaultAsync(); if (orderItem == null) { throw new RestaurantNotFoundException("Nem létező rendelési tétel!"); } await StatusService.CheckRightsForStatus(orderItem.Order.OrderSession.Status, orderItem.Order.Status); orderItem.Quantity = model.Quantity; orderItem.Comment = model.Comment; await DbContext.SaveChangesAsync(); }
public async Task ModifyOrderItem(int orderId, int itemId, OrderItemModModel model) => await OrderService.ModifyOrderItem(orderId, itemId, model);