static void Main(string[] args) { List <PayRow> payLog = new List <PayRow>(); IEnumerable <Employee> employees = CreateEmployeeMocks(); Console.WriteLine("### Payroll ###" + Environment.NewLine); foreach (Employee employee in employees) { if (employee.IsPayDay()) { PayRow payRow = employee.RecordPay(); payLog.Add(payRow); } } Console.WriteLine("Pay log of {0}" + Environment.NewLine, DateTime.Now.ToString("dd/MM/yyyy")); foreach (PayRow payRow in payLog) { Console.WriteLine(payRow); } Console.ReadKey(); }
public override PayRow RecordPay() { PayRow payRow = null; if (IsPayDay()) { payRow = new PayRow(Id, Name, salary, DateTime.Now.Date); } return(payRow); }
public override PayRow RecordPay() { PayRow payRow = null; if (IsPayDay()) { DateTime toDay = DateTime.Now.Date; foreach (Sale sale in _sales) { if (toDay.Equals(sale.Date)) { salary += sale.Amount * commissionPercentage; } } payRow = new PayRow(Id, Name, salary, toDay); _sales = new List <Sale>(); } return(payRow); }
public override PayRow RecordPay() { PayRow payRow = null; if (IsPayDay()) { DateTime toDay = DateTime.Now.Date; DateTime firstDayOfThisWeek = toDay.AddDays(-5); foreach (WorkedHours workedHours in _workedHours) { if (firstDayOfThisWeek <= workedHours.Date && workedHours.Date < toDay) { salary += workedHours.Hours * hourlyPay; } } payRow = new PayRow(Id, Name, salary, toDay); _workedHours = new List <WorkedHours>(); } return(payRow); }