示例#1
0
 public IResult Put(int id, [FromBody] Order order)
 {
     using (SkateboardContext context = new SkateboardContext())
     {
         int res    = 0;
         var entity = context.Orders.FirstOrDefault(e => e.OrderId == id);
         if (order.PreparationDate != null && order.DeliveryDate != null)
         {
             res = DateTime.Compare((DateTime)order.PreparationDate, (DateTime)order.DeliveryDate);
         }
         if (order.PreparationDate == null || entity.PreparationDate == null && order.DeliveryDate != null)
         {
             res = DateTime.Compare((DateTime)entity.PreparationDate, (DateTime)order.DeliveryDate);
         }
         else if (order.PreparationDate != null && order.DeliveryDate == null)
         {
             res = DateTime.Compare((DateTime)order.PreparationDate, (DateTime)entity.DeliveryDate);
         }
         if (res < 0)
         {
             entity.PreparationDate = order.PreparationDate;
             entity.DeliveryDate    = order.DeliveryDate;
             context.SaveChanges();
             return(new SuccessResult("Order is Updated"));
         }
     }
     return(new ErrorResult("Order isn't Updated"));
 }
示例#2
0
 public string AddDeck(Deck deck)
 {
     try
     {
         _context.Deck.Add(deck);
         _context.SaveChanges();
         return("successs");
     }
     catch (Exception e)
     {
         return(e + "Error");
     }
 }