public async Task <IActionResult> Edit(string id, [Bind("Id,IdFood,IdResturant,Available")] ResturantsFood resturantsFood) { if (id != resturantsFood.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(resturantsFood); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ResturantsFoodExists(resturantsFood.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["IdFood"] = new SelectList(_context.Tblfoods, "Id", "Id", resturantsFood.IdFood); ViewData["IdResturant"] = new SelectList(_context.Tblresturants, "Id", "Id", resturantsFood.IdResturant); return(View(resturantsFood)); }
public async Task <IActionResult> Create([Bind("Id,IdFood,IdResturant,Available")] ResturantsFood resturantsFood) { if (ModelState.IsValid) { _context.Add(resturantsFood); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdFood"] = new SelectList(_context.Tblfoods, "Id", "Id", resturantsFood.IdFood); ViewData["IdResturant"] = new SelectList(_context.Tblresturants, "Id", "Id", resturantsFood.IdResturant); return(View(resturantsFood)); }