Ejemplo n.º 1
0
        public JsonResult GetFeesStructure(FeesStructureFilter feesStructureFilter, string classStatus)
        {
            try
            {
                var structure = studentCredentials.GetFeesStructure(feesStructureFilter, classStatus);
                if (!structure.Success)
                {
                    return(Json(structure));
                }

                return(Json(new ReturnData <List <FeeStructureStageViewModel> >
                {
                    Success = structure.Success,
                    Message = structure.Message,
                    Data = structure.Data
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops,seems and error occured while fetching fee statement " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 2
0
 public JsonResult GetClassStatus()
 {
     try
     {
         var token = _tokenValidator.Validate(HttpContext);
         if (!token.Success)
         {
             return(Json(new ReturnData <string>
             {
                 Success = false,
                 NotAuthenticated = true,
                 Message = $"Unauthorized:-{token.Message}",
             }));
         }
         var result   = _unisolApiProxy.GetClassStatus().Result;
         var response = new ProcessJsonReturnResults <dynamic>(result).UnisolApiData;
         return(Json(response));
     }
     catch (Exception ex)
     {
         return(Json(new ReturnData <string>
         {
             Success = false,
             Message = "Oops,an error, please contact admin " + ErrorMessangesHandler.ExceptionMessage(ex)
         }));
     }
 }
Ejemplo n.º 3
0
 public JsonResult GetFeesStatement([FromBody] RegisterViewModel reg, string classStatus)
 {
     try
     {
         var feeStatement = studentCredentials.GetFeesStatement(reg.RegNumber, classStatus);
         return(Json(feeStatement));
     }
     catch (Exception ex)
     {
         return(Json(new ReturnData <List <bool> >
         {
             Success = false,
             Message = "Oops,an error occured.Please contact administrator " +
                       ErrorMessangesHandler.ExceptionMessage(ex)
         }));
     }
 }
Ejemplo n.º 4
0
 public JsonResult GetStudentsResults([FromBody] TranscriptRequestViewModel transcriptModel, string classStatus)
 {
     try
     {
         var currentYearResults = studentCredentials.GetYearResults(transcriptModel, classStatus);
         return(Json(currentYearResults));
     }
     catch (Exception ex)
     {
         return(Json(new ReturnData <List <bool> >
         {
             Success = false,
             Message = "Oops,an error occured.Please contact administrator " +
                       ErrorMessangesHandler.ExceptionMessage(ex)
         }));
     }
 }
Ejemplo n.º 5
0
 public JsonResult ReturnStudentsYearsBeenInSchool([FromBody] RegisterViewModel reg, string classStatus)
 {
     try
     {
         var studentYears = studentCredentials.GetYearsStudentHasBeenToSchool(reg.RegNumber, classStatus);
         return(Json(studentYears));
     }
     catch (Exception ex)
     {
         return(Json(new ReturnData <List <bool> >
         {
             Success = false,
             Message = "Oops,an error occured.Please contact administrator " +
                       ErrorMessangesHandler.ExceptionMessage(ex)
         }));
     }
 }
Ejemplo n.º 6
0
        public JsonResult GetStudentsExamTimetable([FromBody] RegisterViewModel reg, string classStatus)
        {
            try
            {
                var validStudentRegister = studentCredentials.GetStudentDetails(reg.RegNumber, classStatus);
                if (!validStudentRegister.Success)
                {
                    return(Json(validStudentRegister));
                }

                var validSemisterUnits = _studentServices.GetSemisterSubjects(reg.RegNumber, classStatus);
                if (!validSemisterUnits.Success)
                {
                    return(Json(validSemisterUnits));
                }

                var studentClass = _studentServices.GetClass(reg.RegNumber, classStatus);
                if (!studentClass.Success)
                {
                    return(Json(studentClass));
                }

                var campus      = studentClass.Data?.Campus ?? "";
                var currentTerm = _studentServices.GetCurrentTerm(reg.RegNumber, classStatus);
                if (!currentTerm.Success)
                {
                    return(Json(currentTerm));
                }

                var currentSession        = currentTerm.Data?.Names ?? "";
                var examTimetableResponse = GetExamTimetable(validSemisterUnits.Data, currentSession, campus);
                return(Json(examTimetableResponse));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <List <bool> >
                {
                    Success = false,
                    Message = "Oops,an error occured.Please contact administrator " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 7
0
        public JsonResult GetCurrentSemUnits(string userCode, string classStatus)
        {
            try
            {
                var validStudentRegister = studentCredentials.GetStudentDetails(userCode, classStatus);
                if (!validStudentRegister.Success)
                {
                    Json(validStudentRegister);
                }

                var semisterUnits = _studentServices.GetSemisterSubjects(userCode, classStatus);

                return(Json(semisterUnits));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <List <bool> >
                {
                    Success = false,
                    Message = "Oops,an error occured.Please contact administrator " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 8
0
        public JsonResult SaveStudentsUnits(CurriculumUnitsModel curriculumUnitsModel, string classStatus)
        {
            var studClass = _studentServices.GetClass(curriculumUnitsModel.UserCode, classStatus);

            if (!studClass.Success)
            {
                return(Json(studClass));
            }

            var programme = _studentServices.GetProgramme(curriculumUnitsModel.UserCode, classStatus);

            if (!programme.Success)
            {
                return(Json(programme));
            }

            var maxRegUnits = studClass.Data?.MaxUnits == 0 ? programme.Data?.MaxUnits : studClass.Data?.MaxUnits;

            if (curriculumUnitsModel.CurriculumUnits.Count > maxRegUnits)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = $"Sorry, you can only register a maximum of {maxRegUnits} units for the current semester"
                }));
            }

            try
            {
                if (_context.SysSetup.Any(s => Convert.ToDateTime(s.UnitRegDeadLine) < DateTime.Now.Date))
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Oops,seems unit registration deadline has passed"
                    }));
                }

                var hasReported = studentCredentials.ValidateSessionReporting(curriculumUnitsModel.UserCode, classStatus);
                if (!hasReported.Success)
                {
                    return(Json(hasReported));
                }

                if (hasReported.Data != null)
                {
                    if (hasReported.Data.Status.Equals("Pending"))
                    {
                        return(Json(new ReturnData <string>
                        {
                            Success = false,
                            Message = "Sorry, your reporting status is still pending. Kindly contact admin"
                        }));
                    }
                }

                var feePolicyComplied = studentCredentials.ReturnFeesPolicyCompliance(curriculumUnitsModel.UserCode, classStatus, "UNIT");
                if (!feePolicyComplied.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = $"Sorry! Fees payment is required as per the policy before registering for the units. The policy is {feePolicyComplied.Data}% "
                    }));
                }

                var termResponse = _studentServices.GetCurrentTerm(curriculumUnitsModel.UserCode, classStatus);
                if (!termResponse.Success)
                {
                    return(Json(termResponse));
                }

                curriculumUnitsModel.Semester = termResponse.Data?.Names;

                var studEnrolment = _studentServices.GetEnrollment(curriculumUnitsModel.UserCode, classStatus);
                if (!studEnrolment.Success)
                {
                    return(Json(studEnrolment));
                }

                var studentClass             = studEnrolment.Data?.Class;
                var studentRegisteredSession = _context.ProgUnitReg
                                               .FirstOrDefault(s => s.Class == studentClass && s.Term == curriculumUnitsModel.Semester &&
                                                               s.AdmnNo == curriculumUnitsModel.UserCode);

                if (studentRegisteredSession == null)
                {
                    var progUnitReg = new ProgUnitReg
                    {
                        Class     = studentClass,
                        AdmnNo    = curriculumUnitsModel.UserCode,
                        Term      = curriculumUnitsModel.Semester,
                        Rdate     = DateTime.UtcNow,
                        Personnel = curriculumUnitsModel.UserCode
                    };

                    _context.ProgUnitReg.AddRange(progUnitReg);
                    _context.SaveChanges();

                    if (progUnitReg.Id > 0)
                    {
                        curriculumUnitsModel.CurriculumUnits.ForEach(u => {
                            var subjectSelected = new ProgUnitRegDetail
                            {
                                Ref      = progUnitReg.Id.ToString(),
                                UnitCode = u,
                                Status   = "Pending",
                                Audit    = false
                            };
                            _context.ProgUnitRegDetail.Add(subjectSelected);
                        });

                        _context.SaveChanges();
                    }

                    return(Json(new ReturnData <string>
                    {
                        Success = true,
                        Message = "Unit Registration successful, Pending approval from the Chairman of Department (CoD)"
                    }));
                }

                var progUnitRegDetail = _context.ProgUnitRegDetail.Where(u => u.Ref == studentRegisteredSession.Id.ToString());
                var approvedUnits     = progUnitRegDetail.Where(u => u.Status.ToLower().Equals("approved")).Select(u => u.UnitCode.ToUpper()).ToList();
                if ((curriculumUnitsModel.CurriculumUnits.Count + approvedUnits.Count) > maxRegUnits)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = $"Sorry, you can only register a maximum of {maxRegUnits} units for the current semester"
                    }));
                }

                var pendingUnits = progUnitRegDetail.Where(u => u.Status.ToLower().Equals("Pending"));
                _context.ProgUnitRegDetail.RemoveRange(pendingUnits);

                curriculumUnitsModel.CurriculumUnits.ForEach(u => {
                    if (!approvedUnits.Contains(u.ToUpper()))
                    {
                        var subjectSelected = new ProgUnitRegDetail
                        {
                            Ref      = studentRegisteredSession.Id.ToString(),
                            UnitCode = u,
                            Status   = "Pending",
                            Audit    = false
                        };
                        _context.ProgUnitRegDetail.Add(subjectSelected);
                    }
                });

                _context.SaveChanges();

                return(Json(new ReturnData <string>
                {
                    Success = true,
                    Message = "Unit Registration successful, Pending approval from the Chairman of Department (CoD)"
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops, seems an error has occured on our side.Please contact admin " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 9
0
        public JsonResult GetExamCardUnits(string userCode, string classStatus, bool isPreviousTermCard)
        {
            try
            {
                var termResponse = _studentServices.GetCurrentTerm(userCode, classStatus);
                if (isPreviousTermCard)
                {
                    termResponse = _studentServices.GetPreviousTerm(userCode, classStatus);
                }
                if (!termResponse.Success)
                {
                    return(Json(termResponse));
                }

                var reportingDetails = studentCredentials.ValidateExamCardReporting(userCode, classStatus, isPreviousTermCard);
                if (!reportingDetails.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = reportingDetails.Message
                    }));
                }

                var feePolicyComplied = studentCredentials.ReturnFeesPolicyCompliance(userCode, classStatus, "EXAM");
                if (!feePolicyComplied.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = $"Sorry! Fees payment is required as per the policy before accessing examcard. The policy is {feePolicyComplied.Data}% "
                    }));
                }

                /*----------------End of getting fee balance-------------------*/
                var registeredUnit = _context.ProgUnitRegDetail
                                     .Join(_context.ProgUnitReg,
                                           progUnitRegDtl => Convert.ToInt32(progUnitRegDtl.Ref),
                                           progUnitReg => progUnitReg.Id,
                                           (progUnitRegDtl, progUnitReg) =>
                                           new
                {
                    progUnitRegDtl.Status,
                    progUnitReg.Rdate,
                    progUnitReg.Term,
                    progUnitReg.Class,
                    progUnitRegDtl.UnitCode,
                    progUnitReg.AdmnNo
                })
                                     .Where(uR => uR.AdmnNo == userCode && uR.Term == termResponse.Data.Names
                                            ).Distinct().ToList();

                if (!registeredUnit.Any())
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Oops,seems you have not registered for any unit"
                    }));
                }

                registeredUnit = registeredUnit.Where(u => u.Status.CaseInsensitiveContains("approved")).ToList();
                if (!registeredUnit.Any())
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        Message = "Sorry, registered units have not yet been approved. Kindly contact admin"
                    }));
                }

                var unitsWithNames = registeredUnit.Join(
                    _context.Subjects,
                    regUnits => regUnits.UnitCode,
                    sub => sub.Code,
                    (regUnits, sub) => new
                {
                    regUnits.Term,
                    regUnits.Status,
                    regUnits.UnitCode,
                    regUnits.AdmnNo,
                    sub.Names,
                    sub.CreditUnits
                }
                    ).ToList();

                var units = new List <dynamic>();
                unitsWithNames.ForEach(u => {
                    units.Add(new {
                        u.Term, u.Status, u.UnitCode, u.AdmnNo, u.Names, u.CreditUnits
                    });
                });

                return(Json(new ReturnData <List <dynamic> >
                {
                    Success = true,
                    Message = "",
                    Data = units
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops,seems you have not not registered for any unit " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 10
0
        public JsonResult GetStudentsStudyTimetable([FromBody] RegisterViewModel reg, string classStatus)
        {
            try
            {
                reg.RegNumber = reg?.RegNumber ?? "";
                var unitsResponse = studentCredentials.GetUnits(reg.RegNumber, classStatus, "Session Units");
                if (!unitsResponse.Success)
                {
                    return(Json(unitsResponse));
                }

                var units = new List <TimetableUnitModel>();
                foreach (var yearlyUnits in unitsResponse.Data.StudentCurriculumViewModel)
                {
                    foreach (var semesterUnits in yearlyUnits.Semesters)
                    {
                        foreach (var semesterUnit in semesterUnits.CurriculumUnits)
                        {
                            string unitCode = semesterUnit?.UnitCode ?? "";
                            units.Add(new TimetableUnitModel
                            {
                                UnitCode = unitCode.ToUpper(),
                                UnitName = semesterUnit.UnitName
                            });
                        }
                    }
                }

                var validSemisterUnits = _studentServices.GetSemisterSubjects(reg.RegNumber, classStatus);
                if (validSemisterUnits.Success && validSemisterUnits.Data.Count > 1)
                {
                    var registeredUnits = validSemisterUnits.Data.Select(u => u.Code.ToUpper()).ToList();
                    units = units.Where(u => registeredUnits.Contains(u.UnitCode.ToUpper())).ToList();
                }

                var studentClass = _studentServices.GetClass(reg.RegNumber, classStatus);
                if (!studentClass.Success)
                {
                    return(Json(studentClass));
                }

                var campus      = studentClass.Data?.Campus ?? "";
                var classType   = studentClass.Data?.ClassType ?? "";
                var currentTerm = _studentServices.GetCurrentTerm(reg.RegNumber, classStatus);
                if (!currentTerm.Success)
                {
                    return(Json(currentTerm));
                }

                var studyMode         = _context.Register.FirstOrDefault(r => r.AdmnNo.ToUpper().Equals(reg.RegNumber.ToUpper()))?.StudyMode ?? "";
                var lecturer          = "";
                var currentSession    = currentTerm.Data?.Names ?? "";
                var timetableResponse = GetStudyTimetable(units, lecturer, currentSession, campus, studyMode);
                return(Json(timetableResponse));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <List <bool> >
                {
                    Success = false,
                    Message = "Oops,an error occured.Please contact administrator " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 11
0
        public JsonResult GetFeesYears(string progCode, string classStatus)
        {
            try
            {
                var feeStructProg = _context.FeesPerProg.FirstOrDefault(f => f.ProgCode == progCode);
                if (feeStructProg == null)
                {
                    return(Json(new ReturnData <List <YearWithSemesterViewModel> >
                    {
                        Success = false,
                        Message = "Sorry, Your fee structure not found. Kindly contact admin",
                    }));
                }

                var feeStructProgDetails = _context.FeesPerProgDetail.Where(f => f.Ref == "" + feeStructProg.Id).ToList();

                var academicYears = feeStructProgDetails
                                    .GroupBy(d => d.Stage)
                                    .Select(grp => grp.First())
                                    .ToList();

                var classWithSemesters = new List <YearWithSemesterViewModel>();

                academicYears.ForEach(y =>
                {
                    var semesters = new List <StudentSemesterYear>();
                    feeStructProgDetails.ForEach(s =>
                    {
                        if (s.Stage == y.Stage)
                        {
                            semesters.Add(new StudentSemesterYear
                            {
                                Id          = s.Ref,
                                YearOfStudy = s.Stage,
                                Ref         = s.Ref,
                                Semester    = s.Term
                            });
                        }
                    });


                    classWithSemesters.Add(
                        new YearWithSemesterViewModel
                    {
                        Academicyear = y.Stage,
                        Semesters    = semesters
                    }
                        );
                });
                return(Json(new ReturnData <List <YearWithSemesterViewModel> >
                {
                    Success = true,
                    Message = "",
                    Data = classWithSemesters
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops!  something went wrong while retrieving data, please try again " +
                              ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }
Ejemplo n.º 12
0
        public JsonResult ReportOnline(ReportOnlineViewModel reportOnlineViewModel)
        {
            try
            {
                var token = _tokenValidator.Validate(HttpContext);
                if (!token.Success)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = $"Unauthorized:-{token.Message}",
                    }));
                }

                if (token.Role != Role.Student)
                {
                    return(Json(new ReturnData <string>
                    {
                        Success = false,
                        NotAuthenticated = true,
                        Message = "Sorry, you are not authorized to perform this action",
                    }));
                }

                var classStatus = _context.Settings.FirstOrDefault()?.ClassStatus;
                var hostelrooms = _unisolApiProxy.ReportOnline(reportOnlineViewModel, classStatus).Result;
                var jdata       = JsonConvert.DeserializeObject <ReturnData <dynamic> >(hostelrooms);
                if (!jdata.Success)
                {
                    return(Json(new ReturnData <bool>
                    {
                        Success = false,
                        Message = jdata.Message
                    }));
                }

                return(Json(new ReturnData <List <HostelRooms> >
                {
                    Success = true,
                    Message = jdata.Message
                }));
            }
            catch (Exception ex)
            {
                return(Json(new ReturnData <string>
                {
                    Success = false,
                    Message = "Oops,An error occured while trying saving your reporting, please try again " + ErrorMessangesHandler.ExceptionMessage(ex)
                }));
            }
        }