public async Task <IEnumerable <Employee> > GetAllAsync() { var employees = await _employeeRepository.GetAllAsync(); return(employees.Select(employee => { employee.AnnualSalary = SalaryFactory.GetSalary(employee).AnnualSalary(); return employee; })); }
public async Task <IEnumerable <Employee> > GetByIdAsync(int id) { var employees = await _employeeRepository.GetAllAsync(); return(employees.Where((employee) => employee.Id == id).Select(employee => { employee.AnnualSalary = SalaryFactory.GetSalary(employee).AnnualSalary(); return employee; })); }
public void GetSalary(TypeSalary key, params uint[] value) { switch (key) { case TypeSalary.Hourly: { EmployeeBase salary = SalaryFactory.GetSalary(TypeSalary.Hourly, 140, 400); EmployeeHourly result = salary as EmployeeHourly; Assert.AreSame(salary, result); break; } case TypeSalary.Rate: { EmployeeBase salary = SalaryFactory.GetSalary(TypeSalary.Rate, 180, 100000, 180); EmployeeRate result = salary as EmployeeRate; Assert.AreSame(salary, result); break; } } }
/// <summary> /// Кнопка добавления случайного объекта /// </summary> private void AddRandomObject_Click(object sender, EventArgs e) { var randomCase = new Random(); var random = new Random(); uint workTime = (uint)random.Next(1, 372); switch (randomCase.Next(1, 3)) { case 1: { uint costPerHour = (uint)random.Next(1, 1400); bindingSource.Add(SalaryFactory.GetSalary(TypeSalary.Hourly, workTime, costPerHour)); break; } case 2: { uint rate = (uint)random.Next(1, 372); uint salary = (uint)random.Next(1, 1000000); bindingSource.Add(SalaryFactory.GetSalary(TypeSalary.Rate, workTime, salary, rate)); break; } } }