public ActionResult EventSignup(string firstName, string lastName, string email, int eventId)
        {
            var db = new HockeySignupsDb(_connectionString);
            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. Jerk.";
                return RedirectToAction("Index");
            }
            else if (status == EventStatus.Full)
            {
                TempData["Error"] = "Nice try sucker....";
                return RedirectToAction("Index");
            }
            EventSignup s = new EventSignup
            {
                Email = email,
                FirstName = firstName,
                LastName = lastName,
                EventId = eventId
            };
            db.AddEventSignup(s);

            TempData["Message"] =
                "You have succesfully signed up for this weeks game, looking forward to checking you into the boards!";
            return RedirectToAction("Index");
        }
 public void AddEventSignup(EventSignup es)
 {
     using (SqlConnection connection = new SqlConnection(_connectionString))
         using (SqlCommand cmd = connection.CreateCommand())
         {
             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);
             connection.Open();
             cmd.ExecuteNonQuery();
         }
 }
        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;
        }
 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();
     });
 }