Esempio n. 1
0
        public IActionResult Add(AddPizzaBindingModel bindingModel, HttpSession currentSession, HttpResponse response)
        {
            if (!this.signInManger.IsAuthenticated(currentSession))
            {
                this.Redirect(response, "/users/signin");
                return(null);
            }

            this.pizzasService.AddPizza(bindingModel, currentSession);
            this.Redirect(response, "/menu/index");
            return(null);
        }
Esempio n. 2
0
        internal void AddPizza(AddPizzaBindingModel bindingModel, HttpSession currentSession)
        {
            User currentUser = this.context.Sessions
                               .First(s => s.SessionId == currentSession.Id).User;

            currentUser.PizzaSuggestions.Add(new Pizza()
            {
                Title    = bindingModel.Title,
                ImageUrl = bindingModel.Url,
                Recipe   = bindingModel.Recipe
            });

            this.context.SaveChanges();
        }
Esempio n. 3
0
        public IActionResult Add(HttpSession session, HttpResponse response, AddPizzaBindingModel model)
        {
            if (!this.signInManager.IsAuthenticated(session))
            {
                this.Redirect(response, "/users/signin");
                return(null);
            }

            using (PizzaMoreMVCContext context = new PizzaMoreMVCContext())
            {
                ConfigureMapper(session, context);
                Pizza pizzaEntity = Mapper.Map <Pizza>(model);
                context.Pizzas.Add(pizzaEntity);
                context.SaveChanges();
            }

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