public async Task <IActionResult> Edit(int id, [Bind("Id,Name,price,Unit,Quantity,ShortDescription,CategoryId")] Product product) { if (id != product.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Id", product.CategoryId); return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Email")] Subscribe subscribe) { if (id != subscribe.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(subscribe); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SubscribeExists(subscribe.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(subscribe)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,DeletedDate")] 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,Title,Body,Image,PostDate")] Post post) { if (id != post.Id) { return(NotFound()); } if (ModelState.IsValid) { try { db.Update(post); await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PostExists(post.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(post)); }