Example #1
0
        public ActionResult Create([Bind(Include = "LadderRuleId,challengeRange,challengeLower,numLadders")] LadderRule ladderRule)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }

            try
            {
                if (ModelState.IsValid)
                {
                    db.LadderRules.Add(ladderRule);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            catch
            {
                TempData["Message"] = "ERROR - Please try again";
                return(View());
            }

            return(View(ladderRule));
        }
Example #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            LadderRule ladderRule = db.LadderRules.Find(id);

            db.LadderRules.Remove(ladderRule);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #3
0
        // GET: LadderRule/Details/5
        public ActionResult Details(int?id)
        {
            if (Session["currentUser"] == null)
            {
                TempData["message"] = "Please login to continue.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1)
            {
                TempData["message"] = "You must be an administrator to access this page.";
                return(RedirectToAction("VerifyLogin", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LadderRule ladderRule = db.LadderRules.Find(id);

            if (ladderRule == null)
            {
                return(HttpNotFound());
            }
            return(View(ladderRule));
        }