public IActionResult add(int DishId) { Dish dish = repository.Dishes.FirstOrDefault(d => d.DishId == DishId); if (dish != null) { repository.SaveDish(dish); TempData["message"] = $"{dish.Name} is selecteerbaar"; } return(RedirectToAction("Import")); }
public IActionResult CreateDish(DishViewModel data) { Console.WriteLine(data); Dish dish = new Dish { Name = data.Name, Description = data.Description, Price = data.Price, Starter = data.Starter, MainDish = data.MainDish, Dessert = data.Dessert, Salt = data.Salt, Glutes = data.Glutes, Diabetes = data.Diabetes, }; { using (var ms = new MemoryStream()) { data.Image.CopyTo(ms); dish.Image = ms.ToArray(); } } repository.SaveDish(dish); TempData["message"] = $"{dish.Name} is opgeslagen"; return(RedirectToAction("Index", "Home")); }