Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        /// <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);
        }