public ActionResult Index(int? id) { ApplicationUser user = userManager.FindById(User.Identity.GetUserId()); var companies = companyService.GetCompaniesByUser(user); var positions = positionService.GetPositions(); ViewBag.Companies = companies; ViewBag.Positions = positions; ViewBag.FirstComapanyId = (companies.Count() != 0) ? companies.FirstOrDefault().Id : 0; ViewBag.FirstPositionId = (positions.Count() != 0 ) ? positions.FirstOrDefault().Id : 0; if (id.HasValue && id != 0) { var employee = employeeService.GetEmployee(id.Value); if (employee != null) { EmployeeInfoModel employeeInfor = new EmployeeInfoModel() { Id = employee.Id, LastName = employee.LastName, FirstName = employee.FirstName, EmployeeCode = employee.EmployeeCode, IdentityNo = employee.Identity.IdentityNo, IdentityDateOfIssue = employee.Identity.DateOfIssue, Gender = employee.Gender, MaritalStatus = employee.MaritalStatus, Nationality = employee.Nationality, Salary = employee.Salary, Photo = employee.Photo, BirthDay = (DateTime)employee.BirthDay, RealSalary = employeeService.GetEmployeeRealSalaryAtDate(employee,DateTime.Now) }; ViewData["employeeInfor"] = employeeInfor; // EmployeeDetailReport empDetailReport = new EmployeeDetailReport(employee); ViewData["report"] = empDetailReport; Session["Empreport"] = empDetailReport; EmployeeFunctionTabViewModel employeeFunctionTabViewModel = CreateEmployeeFunctionViewModelFromEmployee(employee); employeeFunctionTabViewModel.report1 = empDetailReport; return View("EmployeeDetail",employeeFunctionTabViewModel); } } return View(); }
public ActionResult EmployeeInforUpdate(EmployeeInfoModel empolyeeInforUpdate) { if (ModelState.IsValid) { var employee = employeeService.GetEmployee(empolyeeInforUpdate.Id); if (employee != null) { Mapper.Map<EmployeeInfoModel, Employee>(empolyeeInforUpdate, employee); employeeService.EditEmployee(employee); return Json(new { status = "Success", messeage = "OK" }); } return Json(new { status = "Fail", messeage = "Nhân viên không tồn tại" }); } else { return Json(new { status = "Fail", messeage = "Kiểm tra dữ liệu nhập" }); } }