Beispiel #1
0
        public ActionResult PlaceOrder(DIYViewModel selectedIngr)
        {
            var allIngredients = selectedIngr.SelectedIngredients.Split(',')
                                 .Distinct().Where(x => !string.IsNullOrEmpty(x)).ToArray();
            var all   = new List <Ingredient>();
            var total = 0;

            foreach (var ing in allIngredients)
            {
                var i = IngredientHandler.Instance.GetById(int.Parse(ing));
                all.Add(i);
                total += i.Price;
            }

            var favReceipt = new Receipt()
            {
                Name          = "Custom receipt",
                PublishedDate = DateTime.Now,
                Ingredients   = all
            };

            ViewBag.total      = total;
            ViewBag.finaltotal = total + 2;
            ReceiptHandler.Instance.AddReceipt(favReceipt);
            return(View());
        }
Beispiel #2
0
        public ActionResult DIY()
        {
            var model = new DIYViewModel();

            model.Ingredients = IngredientHandler.Instance.GetAll().ToList();
            return(View(model));
        }