public IActionResult <UserSuggestionsViewModel> Suggestions(DeletePizzaBindingModel bindingModel, HttpSession currentSession, HttpResponse response) { if (!this.signInManger.IsAuthenticated(currentSession)) { this.Redirect(response, "/users/signin"); } this.pizzasService.DeletePizza(bindingModel.PizzaId); this.Redirect(response, "/menu/suggestions"); return(null); }
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); } }