Beispiel #1
0
        public ActionResult LatestEvent()
        {
            var   db                = new HockeySignupsDb(_connectionString);
            Event latestEvent       = db.GetLatestEvent();
            EventSignupViewModel vm = new EventSignupViewModel();

            vm.Event       = latestEvent;
            vm.EventStatus = db.GetEventStatus(latestEvent);
            vm.Signup      = new EventSignup();
            if (Request.Cookies["firstName"] != null)
            {
                vm.Signup.FirstName = Request.Cookies["firstName"].Value;
                vm.Signup.LastName  = Request.Cookies["lastName"].Value;
                vm.Signup.Email     = Request.Cookies["email"].Value;
            }
            return(View(vm));
        }
Beispiel #2
0
        public ActionResult EventSignup(string firstName, string lastName, string email, int eventId)
        {
            HockeySignupsDb db     = new HockeySignupsDb(_connectionString);
            Event           e      = db.GetEventById(eventId);
            EventStatus     status = db.GetEventStatus(e);

            if (status == EventStatus.InThePast)
            {
                #region TempData
                TempData["Error"] = "You cannot sign up to a game in the past. Jerk.";
                #endregion
                return(RedirectToAction("Index"));
            }
            if (status == EventStatus.Full)
            {
                #region TempData
                TempData["Error"] = "Nice try sucker....";
                #endregion
                return(RedirectToAction("Index"));
            }
            EventSignup s = new EventSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName,
                EventId   = eventId
            };

            HttpCookie firstNameCookie = new HttpCookie("firstName", s.FirstName);
            HttpCookie lastNameCookie  = new HttpCookie("lastName", s.LastName);
            HttpCookie emailCookie     = new HttpCookie("email", s.Email);

            Response.Cookies.Add(firstNameCookie);
            Response.Cookies.Add(lastNameCookie);
            Response.Cookies.Add(emailCookie);

            db.AddEventSignup(s);
            #region TempData
            TempData["Message"] =
                "You have succesfully signed up for this weeks game, looking forward to checking you into the boards!";
            #endregion

            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult EventSignup(string firstName, string lastName, string email, int eventId)
        {
            var db     = new HockeySignupsDb(Properties.Settings.Default.ConStr);
            var e      = db.GetEventById(eventId);
            var status = db.GetEventStatus(e);

            if (status == EventStatus.InThePast)
            {
                TempData["Error"] = "You cannot sign up to a game in the past!!";
                return(RedirectToAction("Index"));
            }
            if (status == EventStatus.Full)
            {
                TempData["Error"] = "Nice try!";
                return(RedirectToAction("Index"));
            }
            EventSignup s = new EventSignup
            {
                Email     = email,
                FirstName = firstName,
                LastName  = lastName,
                EventId   = eventId
            };

            HttpCookie firstNameCookie = new HttpCookie("firstName", s.FirstName);
            HttpCookie lastNameCookie  = new HttpCookie("lastName", s.LastName);
            HttpCookie emailCookie     = new HttpCookie("email", s.Email);

            Response.Cookies.Add(firstNameCookie);
            Response.Cookies.Add(lastNameCookie);
            Response.Cookies.Add(emailCookie);

            db.AddEventSignup(s);

            TempData["Message"] =
                "You have successfully signed up for this weeks game, looking forward to checking you into the boards!";
            return(RedirectToAction("Index"));
        }