public ActionResult Mine(int? after) { if (!Request.IsAuthenticated) { return View("Error"); } ViewBag.CurrentPage = "mine"; // Reset to 0 if negative or null int afterSpray = after ?? 0; if (afterSpray < 0) afterSpray = 0; SprayListModel sprays = new SprayListModel(); sprays.Start = afterSpray; sprays.Prev = afterSpray - SPRAYS_PER_PAGE < 0 ? 0 : afterSpray - SPRAYS_PER_PAGE; using (var db = new SprayContext()) { long steamId64 = long.Parse(User.Identity.Name); sprays.Sprays = db.Sprays.Where(s => s.Creator.SteamId == steamId64).Where(s => s.Status != Status.DELETED).OrderByDescending(s => s.DateAdded).Skip(afterSpray).Take(SPRAYS_PER_PAGE).ToList(); } sprays.Next = sprays.Sprays.Count < SPRAYS_PER_PAGE ? afterSpray : afterSpray + SPRAYS_PER_PAGE; return View(sprays); }
// // GET: /Home/ public ActionResult Index() { SprayListModel sprays = new SprayListModel(); //sprays.Start = 0; //sprays.Prev = 0; //using (var db = new SprayContext()) //{ // sprays.Sprays = db.Sprays.Where(s => s.Safeness == Safeness.SFW).Where(s => s.Status == Status.PUBLIC).OrderByDescending(s => s.DateAdded).Take(3).ToList(); //} //sprays.Next = 0; return View(sprays); }
public ActionResult Manage(int? after) { /* CHANGEME - This is my Steam ID. If I logged in, I got extra admin options */ if (!Request.IsAuthenticated || (User.Identity.Name != "76561197999489042")) return View("Error"); ViewBag.CurrentPage = "manage"; ViewBag.BrowseMode = "newest"; // Reset to 0 if negative or null int afterSpray = after ?? 0; if (afterSpray < 0) afterSpray = 0; SprayListModel sprays = new SprayListModel(); sprays.Start = afterSpray; sprays.Prev = afterSpray - SPRAYS_PER_PAGE < 0 ? 0 : afterSpray - SPRAYS_PER_PAGE; using (var db = new SprayContext()) { sprays.Sprays = db.Sprays.Where(s => s.Status == Status.UNMODERATED).OrderBy(s => s.DateAdded).Skip(afterSpray).Take(SPRAYS_PER_PAGE).ToList(); } sprays.Next = sprays.Sprays.Count < SPRAYS_PER_PAGE ? afterSpray : afterSpray + SPRAYS_PER_PAGE; return View(sprays); }