示例#1
0
        public IActionResult AlacarteAction(IFormCollection Form)
        {
            var key     = Form.Keys.FirstOrDefault(k => k.Contains("-"));
            var dashPos = key.IndexOf("-");
            var action  = key.Substring(0, dashPos);
            var id      = int.Parse(key.Substring(dashPos + 1));

            switch (action)
            {
            case "add":
                _cartService.AddDish(id);
                break;

            case "remove":
                _cartService.DeleteDish(id);
                break;

            case "customize":
                return(RedirectToAction("Customize", "CartItems", new { cartItemId = id }));

            case "pay":
                return(RedirectToAction("Index", "Payments", new { cartId = id }));
            }
            return(RedirectToAction("Index"));
        }
示例#2
0
        public IActionResult MakeOrderAction(IFormCollection form)
        {
            var key     = form.Keys.FirstOrDefault(k => k.Contains("-"));
            var dashPos = key.IndexOf("-");
            var action  = key.Substring(0, dashPos);
            var id      = int.Parse(key.Substring(dashPos + 1));

            switch (action)
            {
            case "add":
                _cartService.AddDish(id);
                break;

            case "increase":
                _cartService.IncreaseNumberOfDishInCart(id);
                break;

            case "decrease":
                _cartService.DecreaseNumberOfDishInCart(id);
                break;

            case "delete":
                _cartService.RemoveDish(id);
                break;

            case "customize":
                return(RedirectToAction("Edit", "CartItems", new { Id = id }));

            case "pay":
                return(RedirectToAction("Edit", "Orders", new { Id = id }));
            }

            return(RedirectToAction("Index", _context.Categories.ToList()));
        }