public double CalculateBonus(Personnel personnel) { double bonusRate = 0.0D; switch (personnel.PersonnelType) { case Personnel.PersonnelTypes.FullTime: bonusRate = 0.15D; break; // other types of personnel in the future default: break; } // processing here return(personnel.AnnualSalary * bonusRate); }
static void Main(string[] args) { PersonnelRepository empRepo = new PersonnelRepository(); PayCalculator payCalc = new PayCalculator(); Personnel existingPersonnel = empRepo.GetPersonnelInformation(1); double hourlyRate = payCalc.GetHourlyRate(existingPersonnel); DateTime paySchedule = payCalc.GetPaySchedule(existingPersonnel); double sumDeductibles = payCalc.GetSumOfDeductibles(existingPersonnel); // make some changes on the Personnel info then save empRepo.PersistPersonnelUpdates(existingPersonnel); IReportWriter reportWriter = new ReportWriterDoc(); reportWriter.ReportName = "Document Report"; reportWriter.ChangeReportNumericFormat(); reportWriter.SetReportRecordSortOrder(); reportWriter.SetupReportFields(); reportWriter.ShowReportHeaders(true); reportWriter.GenerateTimeEntryReport(existingPersonnel); IReportWriter reportWriterSpreadsheet = new ReportWriterSpreadsheet(); reportWriterSpreadsheet.ReportName = "Spreadsheet Report"; reportWriterSpreadsheet.ChangeReportNumericFormat(); reportWriterSpreadsheet.SetReportRecordSortOrder(); reportWriterSpreadsheet.SetupReportFields(); reportWriterSpreadsheet.ShowReportHeaders(true); reportWriterSpreadsheet.GenerateTimeEntryReport(existingPersonnel); Personnel newPersonnel = new Personnel(2, "Joe Bloggs", "Foo Department", 16.4D, 27.3D, 25.0D, DateTime.Now, 50000.00D, Personnel.PersonnelTypes.FullTime); empRepo.RegisterPersonnel(newPersonnel); Console.WriteLine($"\nID\tNAME\t\tPERSONNELTYPE\tANNUALSALARY\tBONUS"); Console.WriteLine($"{existingPersonnel.Id}\t{existingPersonnel.Name}\t{existingPersonnel.PersonnelType}\t{existingPersonnel.AnnualSalary}\t\t{payCalc.CalculateBonus(existingPersonnel)}"); Console.WriteLine($"{newPersonnel.Id}\t{newPersonnel.Name}\t{newPersonnel.PersonnelType}\t{newPersonnel.AnnualSalary}\t\t{payCalc.CalculateBonus(newPersonnel)}\n"); empRepo.DeactivatePersonnel(existingPersonnel); }
public double GetHourlyRate(Personnel personnel) { return(personnel.AnnualSalary / (40 * 52)); }
public DateTime GetPaySchedule(Personnel personnel) { return(personnel.PaySchedule); }
public void GenerateTimeEntryReport(Personnel personnel) { // processing here emailSender.SendNotification($"{ReportName}: Report created."); }
public void PersistPersonnelUpdates(Personnel personnel) { logger.Log($"Personnel information updated."); // processing here emailSender.SendNotification("Personnel information updated."); }
public void RegisterPersonnel(Personnel personnel) { logger.Log($"New personnel information created."); // processing here emailSender.SendNotification("New personnel information created."); }