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

                oRepo.updatePrice((int)orderID);

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