public IActionResult Index() { var model = new MenyViewModel { Categories = _context.Categories.ToList(), Dishes = _context.Dishes.Include(d => d.DishIngredients).ToList(), Ingredients = _context.Ingredients.ToList() }; return(View(model)); }
//[Authorize] public ActionResult EndreMeny() { if (Session["IsAuthenticated"] == null) { return(Redirect("/Admin/Index")); } var vm = new MenyViewModel(); vm.Meny = new Meny(); vm.MenyListe = this._unit.Menyer.GetAll().ToList(); return(View("EndreMeny", vm)); }
public async Task <IActionResult> MenyFilter(List <int> selectedTypes, List <int> selectedProducts) { if (selectedTypes.Count == 0 && selectedProducts.Count == 0) { return(RedirectToAction("MenyList")); } else { List <MatrattTyp> dishTypes = _repository.GetAllDishTypes(); foreach (var dt in dishTypes) { foreach (var st in selectedTypes) { if (dt.MatrattTyp1 == st) { dt.Checked = true; } } } List <Produkt> products = await _repository.SelectAll <Produkt>(); foreach (var p in products) { foreach (var sp in selectedProducts) { if (p.ProduktId == sp) { p.Checked = true; } } } List <Matratt> dishes = _repository.GetAllDishesFilter(selectedTypes, selectedProducts).ToList(); MenyViewModel model = new MenyViewModel(dishes, dishTypes, products); return(View("MenyList", model)); } }
public async Task <IActionResult> MenyList() { MenyViewModel model = new MenyViewModel(_repository.GetAllDishes(), _repository.GetAllDishTypes(), await _repository.SelectAll <Produkt>()); return(View(model)); }