Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ActionResult Edit(int? id)
- {
- if (id == null)
- {
- return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
- }
- Product product = db.Product.Find(id);
- if (product == null)
- {
- return HttpNotFound();
- }
- return View(product);
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "Id,Name,Comment,Last_edited")] Product product)
- {
- if (ModelState.IsValid)
- {
- db.Entry(product).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(product);
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public ActionResult Edit([Bind(Include = "Id,Name,Comment")] Product product)
- {
- product.Last_Edited = DateTime.UtcNow;
- if (ModelState.IsValid)
- {
- db.Entry(product).State = EntityState.Modified;
- db.SaveChanges();
- return RedirectToAction("Index");
- }
- return View(product);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement