Example #1
0
        public ActionResult Signup(string firstName, string lastName, string email, int eventId)
        {
            var db = new HockeySignupDb(_connectionString);
            Event e = db.GetEventById(eventId);
            var status = db.GetEventStatus(e);
            if (status != EventStatus.Open)
            {
                return RedirectToAction("Index");
            }

            EventSignup es = new EventSignup
            {
                FirstName = firstName,
                LastName = lastName,
                Email = email,
                EventId = eventId
            };
            db.AddEventSignup(es);

            HttpCookie firstNameCookie = new HttpCookie("firstName", firstName); 
            HttpCookie lastNameCookie = new HttpCookie("lastName", lastName); 
            HttpCookie emailCookie = new HttpCookie("email", email); 

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

            TempData["Message"] = "Signup successfully recorded. Can't wait to check you into the boards!!";
            return RedirectToAction("Index");
        }
Example #2
0
        public IEnumerable<EventSignup> GetEventSignups(int eventId)
        {
            var result = new List<EventSignup>();

            InitiateDbAction(cmd =>
            {
                cmd.CommandText = "SELECT * FROM EventSignups WHERE EventId = @eventId";
                cmd.Parameters.AddWithValue("@eventId", eventId);
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    EventSignup es = new EventSignup
                    {
                        Id = (int)reader["Id"],
                        Email = (string)reader["Email"],
                        EventId = (int)reader["EventId"],
                        FirstName = (string)reader["FirstName"],
                        LastName = (string)reader["LastName"]
                    };
                    result.Add(es);
                }
            });

            return result;
        }
Example #3
0
 public void AddEventSignup(EventSignup es)
 {
     InitiateDbAction(cmd =>
     {
         cmd.CommandText =
             "INSERT INTO EventSignups (Email, FirstName, LastName, EventId) VALUES (@email, @firstName, @lastName, @eventId)";
         cmd.Parameters.AddWithValue("@email", es.Email);
         cmd.Parameters.AddWithValue("@firstName", es.FirstName);
         cmd.Parameters.AddWithValue("@lastName", es.LastName);
         cmd.Parameters.AddWithValue("@eventId", es.EventId);
         cmd.ExecuteNonQuery();
     });
 }