Esempio n. 1
0
        public ActionResult Pizzas()
        {
            var repo   = new PizzaTypeRepository();
            var pizzas = repo.GetPizzaTypes();

            var vm = new PizzasViewModel();

            vm.CountOfPizzas = pizzas.Count;
            vm.PizzaTypes    = pizzas;

            return(View(vm));
        }
Esempio n. 2
0
        public IActionResult <PizzasViewModel> Suggestions(HttpSession session, HttpResponse response)
        {
            if (!this.signInManger.IsAuthenticated(session))
            {
                this.Redirect(response, "/users/signin");
            }

            using (PizzaMoreContext context = new PizzaMoreContext())
            {
                User            currentUser = RetrieveUser(session, context);
                PizzasViewModel viewModel   = new PizzasViewModel()
                {
                    PizzaSuggestions = currentUser.PizzaSuggestions.ToList()
                };

                return(this.View(viewModel));
            }
        }
Esempio n. 3
0
        public IActionResult <PizzasViewModel> Suggestions(DeletePizzaBindingModel model, HttpSession session, HttpResponse response)
        {
            using (PizzaMoreContext context = new PizzaMoreContext())
            {
                Pizza pizzaEntity = context.Pizzas.Find(model.PizzaId);
                context.Pizzas.Remove(pizzaEntity);
                context.SaveChanges();

                User            currentUser = RetrieveUser(session, context);
                PizzasViewModel viewModel   = new PizzasViewModel()
                {
                    PizzaSuggestions = currentUser.PizzaSuggestions.ToList()
                };


                this.Redirect(response, "/menu/suggestions");
                return(null);
            }
        }