public void Execute() { Employee e = PayrollDatabase.GetEmployee(_empId); if (e == null) { throw new InvalidOperationException("Nie ma takiego pracownika."); } HourlyClassification hc = e.Classification as HourlyClassification; if (hc == null) { throw new InvalidOperationException("Próba dodania karty czasu pracy do pracownika zatrudnionego" + " w systemie innym niż godzinowy."); } hc.AddTimeCard(new TimeCard(_date, _hours)); }
public void Execute() { Employee employee = PayRollDatabase.GetEmloyee(_empId); if (employee != null) { HourlyClassification hc = employee.Classification as HourlyClassification; if (hc != null) { hc.AddTimeCard(new TimeCard(_date, _hourse))); } else { throw new InvalidOperationException("Попытка добавить карточку табельного учёта" + "для работника не на почасовой оплате"); } } else { throw new InvalidOperationException("Работник не найден"); } }
public void Execute() { Employee e = PayrollRepository.GetEmployee(_employeeId); if (e != null) { HourlyClassification hc = e.Classification as HourlyClassification; bool isHourlyEmployee = hc != null; if (isHourlyEmployee) { hc.AddTimeCard(_employeeId, _workingDate, _workingHours); } else { throw new InvalidOperationException("non-hourly employee"); } } else { throw new InvalidOperationException("No such employee."); } }