示例#1
0
 public IActionResult UpdateOrder([FromBody] TotalOrderModel orderModel)
 {
     try
     {
         var orderClass   = new OrderClass();
         var getSubOrders = orderClass.UpdateOrder(orderModel);
         var json         = JsonSerializer.Serialize(getSubOrders, new JsonSerializerOptions()
         {
             IgnoreNullValues = true
         });
         return(Ok(json));
     }
     catch (Exception exception)
     {
         return(StatusCode(500, exception.Message));
     }
 }
示例#2
0
        public OrderModels UpdateOrder(TotalOrderModel totalOrderModels)
        {
            using (var context = new TakeThaiContext())
            {
                var orderModels = context.OrderModels.FirstOrDefault(c => c.Id == totalOrderModels.Id);

                if (orderModels != null)
                {
                    orderModels.PaymentMethod = totalOrderModels.PaymentMethod;
                    orderModels.VatReceipt    = totalOrderModels.VatReceipt;

                    context.Update(orderModels);
                    context.SaveChanges();
                }

                return(orderModels);
            }
        }