Пример #1
0
        public bool UpdateGuests(GuestListVM invite)
        {
            bool ok = false;

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand("DELETE FROM guest WHERE event_id = @event_id", conn);
                    cmd.Parameters.AddWithValue("@event_id", invite.eventId);
                    cmd.ExecuteNonQuery();
                    AddGuests(invite);
                    ok = true;
                    return(ok);
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Пример #2
0
        /// <summary>
        /// Adds a list of selected users to an event id to create a GuestList.
        /// </summary>
        /// <param name="Guests"></param>
        /// <param name="id"></param>
        public void AddGuests(GuestListVM invite)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    foreach (int user in invite.guestIds)
                    {
                        SqlCommand cmd = new SqlCommand("INSERT INTO guest (app_user_id, event_id) VALUES (@app_user_id, @event_id)" + _getLastIdSQL, conn);

                        cmd.Parameters.AddWithValue("@app_user_id", user);
                        cmd.Parameters.AddWithValue("@event_id", invite.eventId);
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }
        }
Пример #3
0
 public bool UpdateGuests(GuestListVM invite)
 {
     return(eventDAO.UpdateGuests(invite));
 }
Пример #4
0
 public ActionResult <int> AddGuests(GuestListVM invites)
 {
     eventDAO.AddGuests(invites);
     return(invites.guestIds.Count);
 }