public async Task <IActionResult> Edit(int id, [Bind("MenuID,DrinkID")] DrinkMenu drinkMenu) { if (id != drinkMenu.DrinkID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(drinkMenu); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DrinkMenuExists(drinkMenu.DrinkID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DrinkID"] = new SelectList(_context.Drinks, "Id", "Id", drinkMenu.DrinkID); ViewData["MenuID"] = new SelectList(_context.Menus, "ID", "ID", drinkMenu.MenuID); return(View(drinkMenu)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name")] DrinkCategory drinkCategory) { if (id != drinkCategory.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(drinkCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DrinkCategoryExists(drinkCategory.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(drinkCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,CategoryID")] Drink drink) { if (id != drink.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(drink); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DrinkExists(drink.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewBag.Category = new SelectList(_context.Categories, "ID", "Name", drink.CategoryID); return(View(drink)); }
public void Update(TEntity entity) { Context.Update(entity); Save(); }