示例#1
0
        public ActionResult DecMeal(int?orderID, int?mealID)
        {
            if (Session["UserID"] != null && Session["UserType"].ToString().ToLower() == "chef")
            {
                List <DAL.OrderProduct> orderProducts = opRepo.GetCurrent();
                foreach (DAL.OrderProduct op in orderProducts)
                {
                    if (op.OrderID == orderID)
                    {
                        if (op.MealID == mealID)
                        {
                            if (op.Quantity != 0)
                            {
                                op.Quantity = op.Quantity - 1;
                                opRepo.Update(op);
                            }

                            if (op.Quantity == 0)
                            {
                                opRepo.Delete(op.ID);
                            }
                        }
                    }
                }

                oRepo.updatePrice((int)orderID);


                return(RedirectToAction("EditMeals", "Chef", new { i = orderID }));
            }
            return(RedirectToAction("Login", "Home", new { area = "" }));
        }