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; } }
/// <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; } }
public bool UpdateGuests(GuestListVM invite) { return(eventDAO.UpdateGuests(invite)); }
public ActionResult <int> AddGuests(GuestListVM invites) { eventDAO.AddGuests(invites); return(invites.guestIds.Count); }