Example #1
0
 private RestaurantProvedor2.Models.Dish GetDish()
 {
     RestaurantProvedor2.Models.Dish dish = (RestaurantProvedor2.Models.Dish)Session["Dish"];
     if (dish == null)
     {
         dish = new RestaurantProvedor2.Models.Dish();
         Session["Dish"] = dish;
     }
     return dish;
 }
Example #2
0
        public JsonResult GetData(objCal objCal)
        {
            RestaurantProvedor2.Models.Dish objDish = new RestaurantProvedor2.Models.Dish();
            var iuser = System.Web.HttpContext.Current.User.Identity.GetUserId();
            decimal? allPost = 0.0M;

               var costC = from s in db.IngredientDishes
                        where s.DishId.ToString() == objCal.dishId
                        select s;

            var costR = from s in db.IngredientDishes
                        join r in db.Ingredients on s.IngredientId equals r.IngredientId
                        where s.DishId.ToString() == objCal.dishId && r.RestaurantId == iuser
                        select new objCost() { cost = r.LastCost * s.QuantityNeeded} ;

              var  costRList = costR.ToList();

            if (costC.Count() == costR.Count()) {

                allPost = costRList.Sum(x=> x.cost * int.Parse(objCal.quantity));

            }

            objDish.TotalCost = 1;

            return Json(allPost, JsonRequestBehavior.AllowGet);
        }