/// <summary> /// NAME: Zoey McDonald /// DATE: 2/7/2020 /// CHECKED BY: Ethan Holmes /// /// This is an accessor method for inserting a volunteer event. /// /// </summary> /// <remarks> /// UPDATED BY: N/A /// UPDATED DATE: N/A /// WHAT WAS CHANGED: N/A /// </remarks> public int InsertVolunteerEvent(VolunteerEventVM volunteerEvent) { // Declare the variables int rows = 0; var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_insert_volunteer_event", conn); // Setup the cmd object cmd.CommandType = CommandType.StoredProcedure; // Add the parameters cmd.Parameters.AddWithValue("@EventName", volunteerEvent.EventName); cmd.Parameters.AddWithValue("@EventDescription", volunteerEvent.EventDescription); cmd.Parameters.AddWithValue("@Active", volunteerEvent.Active); // Try to execute the query try { conn.Open(); rows = cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(rows); }
/// <summary> /// NAME: Zoey McDonald /// DATE: 2/7/2020 /// CHECKED BY: Ethan Holmes /// /// This is a method for the volunteer event manager to insert a volunteer event. /// /// </summary> /// <remarks> /// UPDATED BY: N/A /// UPDATED DATE: N/A /// WHAT WAS CHANGED: N/A /// </remarks> public int InsertVolunteerEvent(VolunteerEventVM volunteerEvent) { int rows = 0; try { rows = _accessor.InsertVolunteerEvent(volunteerEvent); } catch (Exception ex) { throw ex; } return(rows); }
/// <summary> /// NAME: Zoey McDonald /// DATE: 2/7/2020 /// CHECKED BY: Ethan Holmes /// /// This is a method for submiting a volunteer event when the 'Submit' button has been clicked. /// /// </summary> /// <remarks> /// UPDATED BY: N/A /// UPDATED DATE: N/A /// WHAT WAS CHANGED: N/A /// </remarks> private void btnSubmitVolunteerEvent_Click(object sender, RoutedEventArgs e) { string volunteerName = txtVolunteerEventTitle.Text.ToString(); string eventDescription = txtVolunteerEventDescription.Text.ToString(); bool volActive = (bool)chkVolunteerEventActive.IsChecked; VolunteerEventVM insertEvent = new VolunteerEventVM() { //VolunteerEventID = 1, EventName = volunteerName, EventDescription = eventDescription, Active = volActive }; int create = _volunteerEventManager.InsertVolunteerEvent(insertEvent); }
public void TestVolunteerManagerCreatesVolunteerEvent() { // Arrange VolunteerEventVM Volevent = new VolunteerEventVM() { EventName = "The Event Name", EventDescription = "The Event Description", Active = true }; int rows = 0; IVolunteerEventManager _volunteerEventManager = new VolunteerEventManager(_volunteerEventAccessor); // Act rows = _volunteerEventManager.InsertVolunteerEvent(Volevent); // Assert Assert.AreEqual(rows, 1); }
/// <summary> /// Creator: Zoey McDonald /// Created: 2/7/2020 /// Approver: Ethan Holmes /// /// This is an fake accessor method for inserting a volunteer event. /// /// </summary> /// <remarks> /// Updater: /// Updated: /// Update: /// </remarks> public int InsertVolunteerEvent(VolunteerEventVM volunteerEvent) { _volunteerEventVMs.Add(volunteerEvent); return(1); }