Пример #1
0
        public async Task <Cook> AddIngredient([Bind("CookID,DishID,IngredientID")] Cook c)
        {
            _context.Add(c);
            await _context.SaveChangesAsync();

            return(c);
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("IngredientID,IngredientName,IngredientDescription")] Ingredient ingredient)
        {
            if (ModelState.IsValid)
            {
                _context.Add(ingredient);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(ingredient));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("MealID,MealName,MealDescription")] Meal meal)
        {
            if (ModelState.IsValid)
            {
                _context.Add(meal);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(meal));
        }
Пример #4
0
        public async Task <IActionResult> Create([Bind("CookID,DishID,IngredientID")] Cook cook)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishID"]       = new SelectList(_context.Dishes, "DishID", "DishID", cook.DishID);
            ViewData["IngredientID"] = new SelectList(_context.Ingredients, "IngredientID", "IngredientID", cook.IngredientID);
            return(View(cook));
        }
Пример #5
0
        public async Task <IActionResult> Create([Bind("ServeID,MealID,MealName,DishID,DishName")] Serve serve)
        {
            if (ModelState.IsValid)
            {
                _context.Add(serve);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DishID"] = new SelectList(_context.Dishes, "DishID", "DishID", serve.DishID);
            ViewData["MealID"] = new SelectList(_context.Meal, "MealID", "MealID", serve.MealID);
            return(View(serve));
        }