public bool UpdateOrders(OrdersEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Orders
                    .Single(e => e.OrderId == model.OrderId);

                entity.CustomerId = model.CustomerId;
                entity.PaymentId  = model.PaymentId;

                return(ctx.SaveChanges() == 1);
            }
        }
Exemple #2
0
        public IHttpActionResult Put(OrdersEdit orders)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateOrdersService();

            if (!service.UpdateOrders(orders))
            {
                return(InternalServerError());
            }

            return(Ok());
        }