public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CustomerSurname,Address,AddressComplement,CEP,State,City,Telephone,Email,SendDate,DeliveryDate")] Order order) { if (id != order.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(order)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,CategoryName,Description")] Category category) { if (id != category.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,SmallDescription,LongDescription,Price,ImgUrl,ImgThumbnailUrl,IsPreferSnack,InStock,CategoryId")] Snack snack) { if (id != snack.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(snack); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SnackExists(snack.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", snack.CategoryId); return(View(snack)); }