コード例 #1
0
        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);
        }
コード例 #2
0
        public ActionResult Auction(long id)
        {
            var db = new EbuyDataContext();
            var auction = db.Auctions.Find(id);

            // The following moved to MultipleResponseFormatsAttribute:
            /*
            // Respond to AJAX requests
            if (Request.IsAjaxRequest())
                return PartialView("Auction", auction);

            // Respond to JSON requests
            if (Request.IsJsonRequest())
                return Json(auction);
            */

            // Default to a "normal" view with layout
            return View("Auction", auction);
        }
コード例 #3
0
 public ActionResult PartialAuction(long id)
 {
     var db = new EbuyDataContext();
     var auction = db.Auctions.Find(id);
     return PartialView("Auction", auction);
 }
コード例 #4
0
 public ActionResult JsonAuction(long id)
 {
     var db = new EbuyDataContext();
     var auction = db.Auctions.Find(id);
     return Json(auction, JsonRequestBehavior.AllowGet);
 }
コード例 #5
0
 public ActionResult Index(int page = 0, int size = 25)
 {
     var db = new EbuyDataContext();
     var auctions = db.Auctions.OrderByDescending(x => x.EndTime).Skip(page * 25).Take(size);
     return View("Auctions", auctions);
 }