public async Task <IActionResult> Edit(int id, [Bind("ProductID,Name")] Product product) { if (id != product.ProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.ProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("OfferProductID,OfferName,ProductID")] OfferProduct offerProduct) { if (id != offerProduct.OfferProductID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(offerProduct); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfferProductExists(offerProduct.OfferProductID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["OfferName"] = new SelectList(_context.Offer, "OfferName", "OfferName", offerProduct.OfferName); ViewData["ProductID"] = new SelectList(_context.Product, "ProductID", "ProductID", offerProduct.ProductID); return(View(offerProduct)); }
public async Task <IActionResult> Edit(string id, [Bind("OfferName")] Offer offer) { if (id != offer.OfferName) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(offer); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OfferExists(offer.OfferName)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(offer)); }