Beispiel #1
0
        public async Task <ActionResult> Edit(EditOrderInputDto model)
        {
            log.LogInformation("Editing order for customer {0} - new customer = {1}", model.CustomerName, model.CustomerName);

            await ordersService.EditOrder(model);

            return(Ok());
        }
        public async Task EditOrder(EditOrderInputDto model)
        {
            using (OrdersDbContext dbContext = new OrdersDbContext()
            {
                ConnectionString = _connectionString
            })
            {
                var order = await dbContext.Orders.FindAsync(model.OrderId);

                if (order == null)
                {
                    throw new Exception(String.Format("Order ID '{0}' not found!", model.OrderId));
                }

                order.CustomerName = model.CustomerName;
                order.ShipperCity  = model.ShipperCity;
                order.IsShipped    = model.IsShipped;

                await dbContext.SaveChangesAsync();
            }
        }