Example #1
0
        public IActionResult Fail([Required] int apId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "你并无学生管理操作权限"
                    }));
                }

                LogPricipalOperation        operation   = _logger.GetDefaultLogPricipalOperation(PrincpalOperationCode.InspectJoinApplication, $"查询编码:{apId}", $"审核学生重考申请 不通过审核 操作类: {nameof(ApplicationForReExamination)}");
                ApplicationForReExamination application = _context.ApplicationForReExaminations.Find(apId);

                if (application != null)
                {
                    application.ApplicationStatus = ApplicationStatus.Fail;
                    _context.LogPricipalOperations.Add(operation);
                    _context.SaveChanges();

                    _email.SendReEmail(application.Email, application.StudentId, application.Student?.Name, application.AddTime, false);
                    return(Json(new
                    {
                        isOk = true,
                        title = "消息提示",
                        message = "审核完毕!"
                    }));
                }
                else
                {
                    _logger.Logger(operation);
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "学生申请记录不存在,或者已经被删除!"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = _analysis.ModelStateDictionaryError(ModelState),
                    title = "错误提示",
                    message = "参数错误,传递了不符合规定的参数"
                }));
            }
        }
Example #2
0
        public IActionResult Delete([Required] int apId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "你并无学生管理操作权限"
                    }));
                }

                ApplicationForReExamination application = _context.ApplicationForReExaminations.Find(apId);
                if (application != null)
                {
                    _context.ApplicationForReExaminations.Remove(application);
                    _context.SaveChanges();
                    return(Json(new
                    {
                        isOk = true,
                        title = "信息提示",
                        message = "删除成功!"
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "学生申请记录不存在,或者已经被删除"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = _analysis.ModelStateDictionaryError(ModelState),
                    title = "错误提示",
                    message = "参数错误,传递了不符合规定的参数"
                }));
            }
        }
Example #3
0
        public IActionResult Pass([Required] int apId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "你并无学生管理操作权限"
                    }));
                }
                LogPricipalOperation operation =
                    _logger.GetDefaultLogPricipalOperation(PrincpalOperationCode.InspectReExamApplication, $"查询编码:{apId}", $"审核学生重考申请 通过审核 操作类:{nameof(ApplicationForReExamination)}");

                ApplicationForReExamination application = _context.ApplicationForReExaminations.FirstOrDefault(app => app.ApplicationExamId == apId && app.ApplicationStatus == ApplicationStatus.Submit);

                if (application != null)
                {
                    operation.PrincpalOperationStatus = PrincpalOperationStatus.Success;
                    application.ApplicationStatus     = ApplicationStatus.Pass;
                    Student student = _context.Student.Find(application.StudentId);
                    if (student == null)
                    {
                        return(Json(new
                        {
                            isOk = false,
                            title = "错误提示",
                            message = "学生不存在,或者已经删除"
                        }));
                    }

                    if (student.IsPassExam)
                    {
                        application.ApplicationStatus = ApplicationStatus.Fail;
                        _context.SaveChanges();
                        return(Json(new
                        {
                            isOk = false,
                            title = "错误提示",
                            message = "此人已经通过考试,自动判定审核失败"
                        }));
                    }
                    else
                    {
                        application.ApplicationStatus = ApplicationStatus.Pass;
                        student.MaxExamCount         += 2;
                        _context.SaveChanges();
                        return(Json(new
                        {
                            isOk = true,
                            title = "消息提示",
                            message = "审核成功"
                        }));
                    }
                }
                else
                {
                    operation.PrincpalOperationStatus = PrincpalOperationStatus.Fail;
                    _logger.Logger(operation);
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "申请不存在,或者已经被审核或删除"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = _analysis.ModelStateDictionaryError(ModelState),
                    title = "错误提示",
                    message = "参数错误,传递了不符合规定的参数"
                }));
            }
        }