Beispiel #1
0
        public async Task <IActionResult> Edit(int id, [Bind("MealTypeId,InstockAmount")] MealInstock mealInstock)
        {
            if (id != mealInstock.MealTypeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(mealInstock);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MealInstockExists(mealInstock.MealTypeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MealTypeId"] = new SelectList(_context.MealType, "MealTypeId", "MealTypeName", mealInstock.MealTypeId);
            return(View(mealInstock));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("MealTypeId,InstockAmount")] MealInstock mealInstock)
        {
            if (ModelState.IsValid)
            {
                _context.Add(mealInstock);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MealTypeId"] = new SelectList(_context.MealType, "MealTypeId", "MealTypeName", mealInstock.MealTypeId);
            return(View(mealInstock));
        }