public ActionResult AddEmployee() { EmplyeeDTO emp = new EmplyeeDTO(); emp.DateOfJoining = DateTime.Now; emp.DepartmentList = departmentService.GetDepartmentList().Select(oo => new SelectListItem() { Text = oo.Name, Value = oo.Id.ToString() }).ToList(); return(View("AddEmployee", emp)); }
public ActionResult AddEmployee(EmplyeeDTO empDto) { if (ModelState.IsValid) { Employee emp = new Employee(); emp.Name = empDto.Name; emp.Address = empDto.Address; emp.AnnualSalary = emp.AnnualSalary; emp.DateOfJoining = empDto.DateOfJoining; emp.DepartementId = empDto.DepartementId; emp.IscurrentEmployee = empDto.IscurrentEmployee; employeeService.AddNewEmployee(emp); RedirectToAction("Index"); } empDto.DepartmentList = departmentService.GetDepartmentList().Select(oo => new SelectListItem() { Text = oo.Name, Value = oo.Id.ToString() }).ToList(); return(View(empDto)); }