예제 #1
0
        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"));
        }
예제 #2
0
        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"));
        }