/// <summary> /// \brief <b>Description</b> /// \details takes all values in a parttime Employee and constructs a string /// to be used in the presentation class to display employee details /// </summary> /// <param name="employee">Parttime employee object</param> /// <returns>string thats formated to be displayed in the presentation class</returns> public static string display(ParttimeEmployee employee, bool shouldLog) { string sinTemp = employee.SIN; sinTemp = sinTemp.Insert(6, " "); sinTemp = sinTemp.Insert(3, " "); string print = "Employee Classification : Part Time \n" + "First Name : " + employee.FirstName + "\n" + "Last Name : " + employee.LastName + "\n" + "Date Of Birth : " + employee.DOB.ToString(DateFormat) + "\n" + "SIN : " + sinTemp + "\n" + "Date Of Hire : " + employee.DateOfHire.ToString(DateFormat) + "\n"; if (employee.DateOfTermination != null) { DateTime date = (DateTime)employee.DateOfTermination; print += "Date Of Termination : " + date.ToString(DateFormat) + "\n"; } print += "Hourly Rate : " + employee.HourlyRate.ToString() + "\n";; if (shouldLog) { //logger.Log("[ParttimeEmployee.Display] Employee: \n" + print); } return(print); }
/// <summary> /// \brief <b>Description</b> /// \details Validates all attributes associated with a ParttimeEmployee /// </summary> /// <param name="ptEmployee"></param> /// <returns>a bool that indicates whether the values to validate are acceptable</returns> public static bool validate(ParttimeEmployee ptEmployee) { bool confirmed = true; bool[] test = new bool[] { validateName(ptEmployee.Type, ptEmployee.FirstName), validateName(ptEmployee.Type, ptEmployee.LastName), validateDob(ptEmployee.DOB), validateSIN(ptEmployee.Type, ptEmployee.SIN, ptEmployee.DOB), FulltimeEmployee.validateStartDate(ptEmployee.DOB, ptEmployee.DateOfHire), FulltimeEmployee.validateStopDate(ptEmployee.DateOfHire, ptEmployee.DateOfTermination), FulltimeEmployee.validatePay(ptEmployee.HourlyRate) }; foreach (bool flag in test) { if (!flag) { confirmed = false; Logging.Log("[ParttimeEmployee.Validate] Employee - " + ptEmployee.LastName + ", " + ptEmployee.FirstName + " (" + ptEmployee.SIN + ") - INVALID"); break; } } return(confirmed); }
/// <summary> /// \brief <b>Description</b> /// \details takes a Parttimeemployee object and puts all attributes into a string[], /// and then joins all items in the string array into a "|" delimited string. /// </summary> /// <param name="emp"></param> /// <returns>returns the string that holds all the attributes of the employee object delimited by "|"</returns> public static string join(ParttimeEmployee emp) { string term = "N/A"; if (emp.DateOfTermination != null) { DateTime date = (DateTime)emp.DateOfTermination; term = date.ToString(DateFormat); } string[] item = new string[] { emp.Type.ToString(), emp.LastName, emp.FirstName, emp.SIN, emp.DOB.ToString(DateFormat), emp.DateOfHire.ToString(DateFormat), term, emp.HourlyRate.ToString() }; return(string.Join("|", item)); }