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")); }
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")); }