public ActionResult Create(Auction auction) { try { if (ModelState.IsValid) { db.Auctions.Add(auction); db.SaveChanges(); } return RedirectToAction("Index"); } catch { return View(auction); } }
public ActionResult Edit(Auction auction) { try { // TODO: Add update logic here if (ModelState.IsValid) { db.Entry(auction).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return RedirectToAction("Index"); } return View(auction); } catch { return View(); } }
public ActionResult Delete(int? id, Auction auc) { try { Auction auction = new Auction(); if (ModelState.IsValid) { if (id == null) return new HttpStatusCodeResult(HttpStatusCode.BadRequest); auction = db.Auctions.Find(id); if (auction == null) return HttpNotFound(); db.Auctions.Remove(auction); db.SaveChanges(); return RedirectToAction("Index"); } return View(auction); } catch { return View(); } }