public async Task <string> Edit(string orderId, string userId, OrderWithoutUserEditModel data) { if (data.Products.Count < 1) { throw new ArgumentException(ErrorMessages.InvalidProducts); } if (!this.db.Orders.Any(o => o.Id == orderId)) { throw new ArgumentException(ErrorMessages.InvalidOrderId); } Order order = await this.db.Orders.FindAsync(orderId); order.LastModificationDate = DateTime.Now; await this.db.SaveChangesAsync(); string modification = LogConstants.OrderChanged; await this.UpdateProductOrders(orderId, data.Products); await this.logger.Log(order.Id, userId, modification); return(orderId); }
public async Task <IActionResult> EditOrder(string id, [FromBody] OrderWithoutUserEditModel order) { return(await this.Execute(true, true, async() => { await this.orders.Edit(id, this.UserId, order); return this.Ok(new { orderId = id }); })); }