public static List <StudentHistoryModel> GetStudentHistory(Guid id)
 {
     try
     {
         List <StudentHistoryModel>      modelList         = new List <StudentHistoryModel>();
         IEnumerable <tblStudentHistory> historyEntityList = new List <tblStudentHistory>();
         historyEntityList = from ordered in _unitOfWork.StudentHistoryRepository.Get(filter: prop => prop.StudentID == id)
                             orderby ordered.Semester descending
                             select ordered;
         foreach (var history in historyEntityList)
         {
             tblCollege collegeEntity = new tblCollege();
             collegeEntity = _unitOfWork.CollegeRepository.Get(filter: prop => prop.CollegeID == history.CollegeID).FirstOrDefault();
             tblDepartment departmentEntity = new tblDepartment();
             departmentEntity = _unitOfWork.DepartmentRepository.Get(filter: prop => prop.DepartmentID == history.DepartmentID).FirstOrDefault();
             StudentHistoryModel newHistory = new StudentHistoryModel()
             {
                 StudentID      = history.StudentID,
                 CollegeName    = collegeEntity.CollegeName,
                 DepartmentName = departmentEntity.DepartmentName,
                 Semester       = history.Semester,
                 DateOfJoining  = history.DateOfJoining
             };
             modelList.Add(newHistory);
         }
         return(modelList);
     }
     catch (Exception e)
     {
         string currentFile = new System.Diagnostics.StackTrace(true).GetFrame(0).GetFileName();
         ErrorLogger.LogException(e, currentFile);
         List <StudentHistoryModel> modelList = new List <StudentHistoryModel>();
         return(modelList);
     }
 }
Beispiel #2
0
        public ActionResult Index(int studentId, string cameFromTitle, bool showRawScale = false, int summaryCount = 0, int detailCount = 0)
        {
            try
            {
                base.SetNavigationLinksUrl();

                ModelServices       modelServices = new ModelServices();
                StudentHistoryModel data          = new StudentHistoryModel();

                ViewBag.StudentId    = studentId;
                ViewBag.ShowRawScale = showRawScale;
                ViewBag.Count        = detailCount + 1;
                ViewBag.SummaryCount = summaryCount + 1;
                SiteUser su = ((SiteUser)Session["SiteUser"]);
                data.History = modelServices.GetStudentHistoryReport(studentId, showRawScale, su.Districts.First().Id);

                tblStudent tempStudent = modelServices.GetStudentById(studentId);
                data.CameFromTitle = cameFromTitle;
                data.Student       = tempStudent.FirstName + " " + tempStudent.LastName;
                data.District      = modelServices.GetDistrictName(int.Parse(tempStudent.DistrictId.ToString()));
                data.School        = modelServices.GetSchoolNameByStudentId(studentId);
                return(View("Index", data));
            }
            catch (Exception ex)
            {
                Logging log = new Logging();
                log.LogException(ex);
                return(View("GeneralError"));
            }
        }
        public List <StudentHistoryModel> GetStudentHistory(Guid studentId)
        {
            var getStudentsHistoryQuery = (from sHistoty in _context.tblStudentHistory
                                           where sHistoty.StudentID == studentId
                                           orderby sHistoty.Semester descending
                                           select sHistoty).ToList();

            List <StudentHistoryModel> lstStudentHistory = new List <StudentHistoryModel>();

            foreach (var entry in getStudentsHistoryQuery)
            {
                var getCollege = (from college in _context.tblCollege
                                  where college.CollegeID == entry.CollegeID
                                  select college.CollegeName).FirstOrDefault();

                var getStudentEmail = (from sName in _context.tblStudent
                                       where sName.StudentID == studentId
                                       select sName.EmailAddress).FirstOrDefault();

                var getDepartment = (from dept in _context.tblDepartment
                                     where dept.DepartmentID == entry.DepartmentID
                                     select dept).FirstOrDefault();

                StudentHistoryModel newEntry = new StudentHistoryModel()
                {
                    StudentID      = studentId,
                    EmailAddress   = getStudentEmail,
                    CollegeName    = getCollege,
                    DepartmentName = getDepartment.DepartmentName,
                    Semester       = entry.Semester,
                    DateOfJoining  = entry.DateOfJoining,
                };
                lstStudentHistory.Add(newEntry);
            }
            return(lstStudentHistory);
        }