コード例 #1
0
ファイル: AcademicController.cs プロジェクト: Omwitsa/portal
        public JsonResult GetStudentDetailsWithDepartment(string userCode, string classStatus)
        {
            try
            {
                var studentProgramme = _studentCredentials.FormatStudentProgramme(userCode, classStatus);
                if (!studentProgramme.Success)
                {
                    return(Json(studentProgramme));
                }

                var studentClass = _studentCredentials.FormatStudentClass(userCode, classStatus);
                if (!studentClass.Success)
                {
                    return(Json(studentClass));
                }

                var studentSemesterYears = _studentCredentials.GetStudentSemesterYear(userCode, classStatus);
                if (!studentSemesterYears.Success)
                {
                    return(Json(studentSemesterYears));
                }

                var studentDepartment = _studentCredentials.FormatStudentDeparment(userCode, classStatus);
                if (!studentDepartment.Success)
                {
                    return(Json(studentDepartment));
                }

                var studentAcademicInfo = new StudentAcademicViewModel
                {
                    StudentProgramme = studentProgramme.Data,
                    StudentClass     = studentClass.Data,
                    StudentDeparment = studentDepartment.Data,
                    StudentSemester  = studentSemesterYears.Data,
                };

                return(Json(new ReturnData <StudentAcademicViewModel>
                {
                    Success = true,
                    Message = "",
                    Data = studentAcademicInfo
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Error = new Error(ex)
                }));
            }
        }
コード例 #2
0
ファイル: AcademicController.cs プロジェクト: Omwitsa/portal
        public JsonResult GetStudentAcademicDetails(string userCode, string classStatus, bool isPreviousTermCard)
        {
            try
            {
                var studentProgram = _studentCredentials.FormatStudentProgramme(userCode, classStatus);
                if (!studentProgram.Success)
                {
                    return(Json(studentProgram));
                }


                var studentClass = _studentCredentials.FormatStudentClass(userCode, classStatus, isPreviousTermCard);
                if (!studentClass.Success)
                {
                    return(Json(studentClass));
                }

                var semesterYear = _studentCredentials.GetStudentSemesterYear(userCode, classStatus, isPreviousTermCard);
                var department   = _studentCredentials.FormatStudentDeparment(userCode, classStatus);
                if (!department.Success)
                {
                    return(Json(department));
                }

                var register            = _context.Register.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(userCode.ToUpper()));
                var studentAcademicInfo = new StudentAcademicViewModel
                {
                    StudentName      = register.Names,
                    Sponsor          = register.Sponsor,
                    StudentProgramme = studentProgram.Data,
                    StudentClass     = studentClass.Data,
                    StudentSemester  = semesterYear.Data,
                    StudentDeparment = department.Data,
                };

                return(Json(new ReturnData <StudentAcademicViewModel>
                {
                    Success = true,
                    Message = "",
                    Data = studentAcademicInfo
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Error = new Error(ex)
                }));
            }
        }
コード例 #3
0
        public JsonResult GetCurrentActiveEvaluations(EvaluationFilter evaluationFilter)
        {
            try
            {
                var token = _tokenValidator.Validate(HttpContext);
                if (!token.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = $"Unauthorized:-{token.Message}",
                    }));
                }
                var currentActive = _context
                                    .EvaluationsCurrentActive
                                    .Join(_context.EvaluationsCurrents,
                                          evaluationsCurrentActive => evaluationsCurrentActive.EvaluationsCurrentId,
                                          evaluationCurrentEvaluation => evaluationCurrentEvaluation.Id,
                                          (evalCurrentAct, evalCurrent) => new
                {
                    evalCurrentAct.Status,
                    evalCurrentAct.StartDate,
                    evalCurrentAct.EndDate,
                    evalCurrentAct.EvaluationsId,
                    evalCurrentAct.EvaluationsCurrentId,
                    evalCurrentAct.Id,
                    evalCurrentAct.EvaluationTarget,
                    TotalUnits = _context
                                 .EvaluationTakenUnitWiseByUsers
                                 .Count(c => c.EvaluationCurrentActiveId == evalCurrentAct.Id),
                    evalCurrent.CurrentEvaluationName,
                }
                                          )
                                    .Where(e => e.Status && e.StartDate.Date >= evaluationFilter.StartDate.Date &&
                                           evaluationFilter.EndDate == null ||
                                           e.EndDate.Date <= (evaluationFilter.EndDate ?? DateTime.Now.Date)).ToList();

                if (!string.IsNullOrEmpty(evaluationFilter.SearchText))
                {
                    currentActive = currentActive.Where(e => e.CurrentEvaluationName.ToLower().Contains(evaluationFilter.SearchText) ||
                                                        e.EvaluationTarget.Equals(evaluationFilter.SearchText)).ToList();
                }

                if (currentActive.Count > 0)
                {
                    var student = new StudentAcademicViewModel();
                    currentActive.ForEach(e =>
                    {
                        /**{  name: 'All', value: 0         },{ name: 'Year', value: 1 },
                         * {name: 'faculty', value: 2
                         * },{name: 'department', value: 3 },  { name: 'programme',value: 4},{name: 'class',value: 5},
                         * {name: 'student',value: 6}
                         */
                    });
                    return(Json(new ReturnData <dynamic>
                    {
                        Success = true,
                        Message = "",
                        Data = currentActive
                    }));
                }

                return(Json(new ReturnData <dynamic>
                {
                    Success = false,
                    Message = "Oops,seems you dont have an evaluation periods create between this dates",
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <dynamic>
                {
                    Success = false,
                    Message = "An error occured ,please try again",
                    Error = new Error(ex)
                }));
            }
        }