コード例 #1
0
ファイル: ApplicationController.cs プロジェクト: kickgod/lab
        public IActionResult Item([Required] int apId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "你并无学生管理操作权限"
                    }));
                }

                ApplicationJoinTheExamination applicationJoin = _context.ApplicationJoinTheExaminations.Find(apId);
                if (applicationJoin != null)
                {
                    return(Json(new
                    {
                        isOk = true,
                        item = new
                        {
                            name = applicationJoin.Name,
                            grade = applicationJoin.Grade,
                            id = applicationJoin.StudentId,
                            sex = applicationJoin.Sex?"女":"男",
                            type = applicationJoin.StudentType == StudentType.UnderGraduate?"本科生":"研究生",
                            insName = _context.Institute.Find(applicationJoin.InstituteId)?.Name,
                            proName = _context.Professions.Find(applicationJoin.ProfessionId)?.Name,
                            email = applicationJoin.Email,
                            reason = applicationJoin.Reason
                        },
                        title = "信息提示",
                        message = "加载成功!"
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "学生申请记录不存在,或者已经被删除"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    error = _analysis.ModelStateDictionaryError(ModelState),
                    title = "错误提示",
                    message = "参数错误,传递了不符合规定的参数"
                }));
            }
        }
コード例 #2
0
ファイル: ApplicationController.cs プロジェクト: kickgod/lab
        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}", "审核学生加入考试申请 不通过审核 ");

                ApplicationJoinTheExamination applicationJoin = _context.ApplicationJoinTheExaminations.Find(apId);
                if (applicationJoin != null)
                {
                    applicationJoin.ApplicationStatus = ApplicationStatus.Fail;
                    _email.SendJoinEmail(applicationJoin.Email, applicationJoin.StudentId, applicationJoin.Name, applicationJoin.AddTime, false, "申请原因说明不详细!或者个人信息有误!");
                    _context.LogPricipalOperations.Add(operation);
                    _context.SaveChanges();
                    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 = "参数错误,传递了不符合规定的参数"
                }));
            }
        }
コード例 #3
0
ファイル: ApplicationController.cs プロジェクト: kickgod/lab
        public IActionResult Delete([Required] int apId)
        {
            if (ModelState.IsValid)
            {
                if (!_analysis.GetLoginUserConfig(HttpContext).Power.StudentManager)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误提示",
                        message = "你并无学生管理操作权限"
                    }));
                }

                ApplicationJoinTheExamination applicationJoin = _context.ApplicationJoinTheExaminations.Find(apId);
                if (applicationJoin != null)
                {
                    _context.ApplicationJoinTheExaminations.Remove(applicationJoin);
                    _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 = "参数错误,传递了不符合规定的参数"
                }));
            }
        }
コード例 #4
0
        public IActionResult Apply([Bind(include: "StudentId,Reason,Email,IDNumber,InstituteId,ProfessionId,Grade,Phone,Name,BirthDate,Sex,StudentType")] ApplicationJoinTheExamination applicationJoinTheExamination)
        {
            if (ModelState.IsValid)
            {
                if (!_context.Institute.Any(i => i.InstituteId == applicationJoinTheExamination.InstituteId))
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "学院不存在!"
                    }));
                }

                Profession pro = _context.Professions.Find(applicationJoinTheExamination.ProfessionId);
                if (pro == null)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "专业不存在!"
                    }));
                }

                if (pro.InstituteId != applicationJoinTheExamination.InstituteId)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "此专业不属于这个学院!"
                    }));
                }

                if ((int)pro.ProfessionType != (int)applicationJoinTheExamination.StudentType)
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "学生性质和专业性质不正确! 例如 研究生学生具有本科生专业!"
                    }));
                }

                if (_context.ApplicationJoinTheExaminations.Any(p => p.StudentId == applicationJoinTheExamination.StudentId && p.ApplicationStatus == ApplicationStatus.Submit))
                {
                    return(Json(new
                    {
                        isOk = false,
                        title = "错误信息",
                        message = "请勿重复提交申请!你尚有尚未审核的申请等待处理中..."
                    }));
                }

                if (!_context.Student.Any(s => s.StudentId == applicationJoinTheExamination.StudentId))
                {
                    applicationJoinTheExamination.Reason            = applicationJoinTheExamination.Reason.Trim();
                    applicationJoinTheExamination.AddTime           = DateTime.Now;
                    applicationJoinTheExamination.Name              = applicationJoinTheExamination.Name.Trim();
                    applicationJoinTheExamination.Email             = applicationJoinTheExamination.Email.Trim();
                    applicationJoinTheExamination.Phone             = applicationJoinTheExamination.Phone.Trim();
                    applicationJoinTheExamination.ApplicationStatus = ApplicationStatus.Submit;

                    _context.ApplicationJoinTheExaminations.Add(applicationJoinTheExamination);
                    _context.SaveChanges();
                    return(Json(new
                    {
                        isOk = true,
                        title = "提示信息",
                        message = "提交成功!请等待审核通过"
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        isOk = false,
                        message = "你的信息已经录入考试系统中!无须申请"
                    }));
                }
            }
            else
            {
                return(Json(new
                {
                    isOk = false,
                    title = "错误信息",
                    message = "输入了非法的不合格的参数"
                }));
            }
        }
コード例 #5
0
ファイル: ApplicationController.cs プロジェクト: kickgod/lab
        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.InspectJoinApplication, $"{apId}", $"审核学生加入考试申请 通过审核");

                ApplicationJoinTheExamination applicationJoin = _context.ApplicationJoinTheExaminations.Find(apId);

                if (applicationJoin != null)
                {
                    //是否已经存在了
                    if (_context.Student.Any(s => s.StudentId == applicationJoin.StudentId))
                    {
                        _email.SendJoinEmail(applicationJoin.Email, applicationJoin.StudentId, applicationJoin.Name, applicationJoin.AddTime, false, "你已经在考试范围内!");
                        _context.SaveChanges();
                        return(Json(new
                        {
                            isOk = false,
                            title = "错误提示",
                            message = "审核结果: 此学生已经在考试范围内! 审核此申请失败."
                        }));
                    }
                    else
                    {
                        Student student = (Student)applicationJoin;
                        // //身份证后六位就是密码
                        student.Password = _encryption.EncodeByMd5(_encryption.EncodeByMd5(student.IDNumber.Substring(student.IDNumber.Length - 6, 6)));

                        SystemSetting setting = _config.LoadSystemSetting();
                        //如果这个学院有对应的模块 然后找到这个模块的 考试设置类
                        var insModule = _context.InstituteToModules.FirstOrDefault(im => im.InstituteId == student.InstituteId);
                        if (insModule != null)
                        {
                            //如果这个模块具有加载类
                            Boolean isHave = setting.ExamModuleSettings.TryGetValue(insModule.ModuleId, out var meSetting);
                            student.MaxExamCount = isHave? meSetting.AllowExamTime:2;
                        }
                        else
                        {
                            //如果学院灭有属于哪个模块
                            student.MaxExamCount = 2;
                        }

                        operation.PrincpalOperationStatus = PrincpalOperationStatus.Success; //日志记录 成功
                        applicationJoin.ApplicationStatus = ApplicationStatus.Pass;

                        _context.LogPricipalOperations.Add(operation);
                        _context.Student.Add(student);
                        _context.SaveChanges();

                        _email.SendJoinEmail(applicationJoin.Email, applicationJoin.StudentId, applicationJoin.Name, applicationJoin.AddTime, true, "");
                        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 = "参数错误,传递了不符合规定的参数"
                }));
            }
        }