コード例 #1
0
        public async Task <IActionResult> CertEdit(CertViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    if (model.ExpireDate < model.CertifyingDate)
                    {
                        throw new Exception("证书失效日期不能早于颁发日期,如果长期有效,请选择一个遥远的日期");
                    }
                    var cert = await _employeeService.GetCertification(model.CertId);

                    cert.ActiveStatus   = model.ActiveStatus;
                    cert.AuthorityUnit  = model.AuthorityUnit;
                    cert.CertifyingDate = model.CertifyingDate;
                    cert.ExpireDate     = model.ExpireDate;
                    cert.Name           = model.CertName;
                    await _employeeService.SaveCertification(cert);

                    return(RedirectToAction(nameof(EmpCerts), new { id = model.EmployeeId }));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
            }
            return(View(model));
        }
コード例 #2
0
        public async Task <IActionResult> CertDelete(CertViewModel model)
        {
            try
            {
                await _employeeService.DeleteCertification(model.CertId);

                return(RedirectToAction(nameof(EmpCerts), new { id = model.EmployeeId }));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(CertEdit), new { id = model.CertId, err = ex.Message }));
            }
        }
コード例 #3
0
        public async Task <IActionResult> Resume(int id)
        {
            var employee = await _employeeService.GetEmployee(id);

            var qualifs = await _sysAdminService.GetReferences(ReferenceTypeEnum.Qualification);

            var model = new ResumeViewModel
            {
                ActiviteStatus     = employee.ActiveStatus,
                CurrentDutyName    = employee.DutyName,
                CurrentProjectName = employee.ProjectName,
                EmployeeID         = employee.ID,
                EmployeeName       = employee.Name,
                OrganizationName   = (await _sysAdminService.GetOrganiztion(employee.OrganizationID)).Name,
                SpecialtyName      = (await _sysAdminService.GetReference(employee.SpecialtyID)).ReferenceValue,
                Title          = employee.Title,
                Certifications = (await _employeeService.GetCertifications(id))
                                 .Select(c => CertViewModel.Create(c, employee, qualifs)).ToArray(),
                Logs = (from il in await _analysisService.GetStaffInLogs(id)
                        select new TransferLog
                {
                    Date = il.InDate,
                    FromDuty = "",
                    FromProject = "",
                    LogType = TransferLogType.In,
                    TimeStamp = il.CreatedOn,
                    ToProject = il.ProjectName,
                    ToDuty = il.DutyName,
                }).Union(
                    from ol in await _analysisService.GetStaffOutLogs(id)
                    select new TransferLog
                {
                    Date        = ol.OutDate,
                    FromDuty    = ol.DutyName,
                    FromProject = ol.ProjectName,
                    LogType     = TransferLogType.Out,
                    TimeStamp   = ol.CreatedOn,
                    ToProject   = "",
                    ToDuty      = "",
                }
                    ).OrderBy(l => l.Date).ThenBy(l => l.TimeStamp).ToArray(),
            };

            return(View(model));
        }
コード例 #4
0
        public async Task <IActionResult> CertEdit(int id, string err)
        {
            try
            {
                var cert = await _employeeService.GetCertification(id);

                if (cert?.ID > 0)
                {
                    var employee = await _employeeService.GetEmployee(cert.EmployeeID);

                    if (employee.ID > 0)
                    {
                        var qulifs = await _sysAdminService.GetReferences(ReferenceTypeEnum.Qualification);

                        var model = CertViewModel.Create(cert, employee, qulifs);
                        if (!string.IsNullOrWhiteSpace(err))
                        {
                            ModelState.AddModelError("", err);
                        }
                        return(View(model));
                    }
                    else
                    {
                        throw (new Exception("证书对应的人员不存在,或许该人员已经被删除"));
                    }
                }
                else
                {
                    throw new Exception("没有找到指定的证书");
                }
            }
            catch (Exception ex)
            {
                var model = new CertViewModel();
                ModelState.AddModelError("", ex.Message);
                return(View(model));
            }
        }