/// <summary> /// CREATOR: Kaleb Bachert /// CREATED: 2020/4/5 /// APPROVER: Lane Sandburg /// /// This method adds a new Active Time Off record /// </summary> /// <remarks> /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> /// <param name="activeTimeOff"></param> public int InsertActiveTimeOff(ActiveTimeOff activeTimeOff) { int rows = 0; var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_insert_active_time_off", conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserID", activeTimeOff.UserID); cmd.Parameters.AddWithValue("@StartDate", activeTimeOff.StartDate); cmd.Parameters.AddWithValue("@EndDate", activeTimeOff.EndDate); try { conn.Open(); rows = cmd.ExecuteNonQuery(); } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(rows); }
/// <summary> /// CREATOR: Kaleb Bachert /// CREATED: 2020/4/2 /// APPROVER: Lane Sandburg /// /// Method that inserts a new ActiveTimeOff record (Approved Time Off) /// </summary> /// <remarks> /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> public int InsertActiveTimeOff(ActiveTimeOff activeTimeOff) { int oldCount = activeTimeOffList.Count; activeTimeOffList.Add(activeTimeOff); return(activeTimeOffList.Count - oldCount); }
/// <summary> /// CREATOR: Kaleb Bachert /// CREATED: 2020/4/2 /// APPROVER: Lane Sandburg /// /// Interface method for inserting Active Time Off, called once a request is approved /// </summary> /// <remarks> /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> /// <param name="activeTimeOff"></param> public bool AddActiveTimeOff(ActiveTimeOff activeTimeOff) { try { return(1 == _requestAccessor.InsertActiveTimeOff(activeTimeOff)); } catch (Exception ex) { throw new ApplicationException("Data not added.", ex); } }
/// <summary> /// CREATOR: Kaleb Bachert /// CREATED: 2020/4/15 /// APPROVER: Lane Sandburg /// /// This method retrieves all Users' ActiveTimeOff /// </summary> /// <remarks> /// UPDATER: NA /// UPDATED: NA /// UPDATE: NA /// /// </remarks> public List <ActiveTimeOff> SelectAllUsersActiveTimeOff() { List <ActiveTimeOff> activeTimeOffs = new List <ActiveTimeOff>(); var conn = DBConnection.GetConnection(); var cmd = new SqlCommand("sp_select_all_users_activeTimeOff", conn); cmd.CommandType = CommandType.StoredProcedure; try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { ActiveTimeOff activeTimeOff = new ActiveTimeOff(); activeTimeOff.UserID = reader.GetInt32(0); activeTimeOff.StartDate = reader.GetDateTime(1); activeTimeOff.EndDate = reader.GetDateTime(2); activeTimeOffs.Add(activeTimeOff); } reader.Close(); } } catch (Exception ex) { throw ex; } finally { conn.Close(); } return(activeTimeOffs); }