コード例 #1
0
 public bool placeOrder([FromBody] PostOrderDto add)
 {
     if (add != null)
     {
         var r = productService.PlaceOrder(add);
         if (r == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
 //post order
 public int PlaceOrder(PostOrderDto order)
 {
     try
     {
         var CartRow           = appDbContext.AddToCart.Where(x => x.OrderDetailsId == order.OrderDetailsId && x.ProductId == order.ProductId && x.IsPurchased == false).FirstOrDefault();
         var cartId            = CartRow.Id;
         var orderStatusPlaced = appDbContext.Status.Where(x => x.StatusName == "OrderPlaced").FirstOrDefault();
         var statusId          = orderStatusPlaced.Id;
         var neworder          = new Orders
         {
             CartId    = cartId,
             OrderDate = order.OrderDate,
             StatusId  = statusId,
             OrderTime = order.OrderDate
         };
         appDbContext.Orders.Add(neworder);
         appDbContext.SaveChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw;
     }
 }