Esempio n. 1
0
 public JsonResult PlaceOrder2()
 {
     {
         RMSEntities ctx = new RMSEntities();
         foreach (var item in ctx.Carts)
         {
             OrderedFood h1 = new OrderedFood()
             {
                 Userid   = Session["Userid"].ToString(),
                 Rname    = item.Rname,
                 Itemname = item.Fooditems,
                 Price    = item.Price,
                 Quantity = item.Quantity.ToString(),
                 Date     = DateTime.Now
             };
             ctx.OrderedFoods.Add(h1);
         }
         var rows = from a in ctx.Carts
                    select a;
         foreach (var row in rows)
         {
             ctx.Carts.Remove(row);
         }
         ctx.SaveChanges();
         int d = 1;
         return(Json(d, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 2
0
        public IActionResult CreateOrderedFood([FromBody] OrderedFoodForCreationDto orderedFoodForCreationDto)
        {
            var orderError = "Please ensure your entered data is correct";

            OrderedFood orderedFood = new OrderedFood();

            if (orderedFoodForCreationDto == null)
            {
                return(BadRequest(orderError));
            }


            orderedFood.FoodId        = orderedFoodForCreationDto.FoodId;
            orderedFood.OrderId       = orderedFoodForCreationDto.OrderId;
            orderedFood.CreatedAtDate = DateTime.Now;

            if (orderedFood.CreatedAtDate == null)
            {
                return(StatusCode(500, "The date is invalid"));
            }
            orderedFood.UpdatedAtDate = orderedFood.CreatedAtDate;

            _orderedFoodRepository.AddOrderedFood(orderedFood);

            if (!_orderedFoodRepository.Save())
            {
                return(StatusCode(500, "A problem happened while handling your request."));
            }

            return(Ok(orderedFood));
        }
Esempio n. 3
0
 public void DeleteOrderedFood(OrderedFood orderedFood)
 {
     _context.OrderedFoods.Remove(orderedFood);
 }
Esempio n. 4
0
 public void AddOrderedFood(OrderedFood orderedFood)
 {
     _context.OrderedFoods.Add(orderedFood);
 }