public ActionResult Create(Auction auction) { if (ModelState.IsValid) { var db = new EbuyDataContext(); db.Auctions.Add(auction); db.SaveChanges(); return RedirectToAction("Details", new { id = auction.Id }); } return View(auction); }
// GET: /Details/ public ActionResult Details() { var auction = new Auction() { Title = "Brand new Widge 2.0", Description = "This is brand new verison 2.0 Widget!", StartPrice = 1.00m, CurrentPrice = 13.40m, EndTime = DateTime.Now }; return View(auction); }
// // GET: /Auctions/Details/5 public ActionResult Details(long id = 0) { var auction = new Ebuy.Website.Models.Auction { Id = id, Title = "Brand new Widget 2.0", Description = "This is a brand new version 2.0 Widget!", StartPrice = 1.00m, CurrentPrice = 13.40m, StartTime = DateTime.Parse("6-15-2012 12:34 PM"), EndTime = DateTime.Parse("6-23-2012 12:34 PM"), }; return View(auction); }
public ActionResult Create(Auction auction) { if (auction.EndTime <= DateTime.Now.AddDays(1)) { ModelState.AddModelError("EndTime", "Action must be at least one day long"); } if (ModelState.IsValid) { var db = new EBuyDataContext(); db.Auctions.Add(auction); db.SaveChanges(); return RedirectToAction("Index"); } return View(auction); }
public static string Auction(this UrlHelper helper, Auction auction) { return helper.Action("Auction", "Auctions", new { key = auction.Key, title = auction.Title }); }
public ActionResult Create(Auction auction) { return View(auction); }