public async Task <IActionResult> ListEmployees(int?id, string msg) { if (!id.HasValue) { throw new Exception("必须传递项目的唯一ID"); } var project = await _projectService.GetProjectById(id.Value); var employees = await _employeeService.GetEmployeesInProject(id.Value, false); var specialities = await _sysAdminService.GetReferences(ReferenceTypeEnum.Specialty); //var duties = await _sysAdminService.GetReferences(ReferenceTypeEnum.Duty); //var qualifs = await _sysAdminService.GetReferences(ReferenceTypeEnum.Qualification); ViewBag.ProjectName = project.FullName; ViewBag.ProjectId = id; var model = (from e in employees select ProjEmployeeViewModel.Create(e, specialities)).ToArray(); if (!string.IsNullOrWhiteSpace(msg)) { ModelState.AddModelError("", msg); } return(View(model)); }
// the result is type of EmployeeQualifState public async Task <JsonResult> GetQualifyState(int employeeId, int?dutyId) { if (!dutyId.HasValue) { dutyId = (await _employeeService.GetEmployee(employeeId)).InDutyID; } var dutyQualifications = await _projectService.GetDutyQualifications(dutyId.Value); var certifications = await _employeeService.GetCertifications(employeeId); EmployeeQualifState state = ProjEmployeeViewModel.EvalQualif( employeeId, dutyId.Value, dutyQualifications, certifications, DateTime.Today); return(new JsonResult(state)); }
/// <summary> /// 处理视图模型,包括ViewBag /// </summary> /// <param name="originModel"></param> /// <returns></returns> async Task <RecruitViewModel> ProcessRecruitViewModel(RecruitViewModel originModel) { var orgs = await _sysAdminService.GetOrganiztions(); var specs = await _sysAdminService.GetReferences(ReferenceTypeEnum.Specialty); var duties = await _sysAdminService.GetReferences(ReferenceTypeEnum.Duty); ViewBag.OrgList = new SelectList(orgs, nameof(Organization.ID), nameof(Organization.Name)); ViewBag.SpecList = new SelectList(specs, nameof(Reference.ID), nameof(Reference.ReferenceValue)); ViewBag.DutyList = new SelectList(duties, nameof(Reference.ID), nameof(Reference.ReferenceValue)); var result = await _employeeService.SearchEmployee(originModel.GetCriteria()); originModel.Total = result.Total; originModel.Candidates = result.Records.Select(e => ProjEmployeeViewModel.Create(e, specs)).ToArray(); return(originModel); }