public ActionResult EmployeeList() { EmployeeListViewModel employeeListViewModel = new EmployeeListViewModel(); EmployeeBusinessLayer employeeBusinessLayer = new EmployeeBusinessLayer(); List <Employee> employees = employeeBusinessLayer.GetEmployees(); List <EmployeeViewModel> employViewModels = new List <EmployeeViewModel>(); foreach (var employee in employees) { EmployeeViewModel employeeViewModel = new EmployeeViewModel(); employeeViewModel.EmployeeName = employee.FirstName + " " + employee.LastName; employeeViewModel.Salary = employee.Salary.Value.ToString("C"); if (employee.Salary > 15000) { employeeViewModel.SalaryColor = "yellow"; } else { employeeViewModel.SalaryColor = "green"; } employViewModels.Add(employeeViewModel); } employeeListViewModel.Employees = employViewModels; return(View("EmployeeList", employeeListViewModel)); }
public ActionResult SaveEmployee(Employee employee) { EmployeeBusinessLayer empBal = new EmployeeBusinessLayer(); empBal.SavEmployee(employee); EmployeeViewModel empViewModel = new EmployeeViewModel(); empViewModel.EmployeeName = employee.FirstName + " " + employee.LastName; empViewModel.Salary = employee.Salary.Value.ToString("C"); if (employee.Salary > 15000) { empViewModel.SalaryColor = "yellow"; } else { empViewModel.SalaryColor = "green"; } return(Json(empViewModel)); }