public ReportVM GetReport(int studentId, int termId) { var db = new ApplicationDbContext(); var reportVm = new ReportVM(); reportVm.StID = GetStudentClassRoom(studentId).StID; reportVm.StudentName = GetStudentClassRoom(studentId).Student.StudentName; reportVm.StudentSurname = GetStudentClassRoom(studentId).Student.StudentSurname; reportVm.GradeName = GetStudentClassRoom(studentId).ClassRoom.GradeName; reportVm.TermName = db.Terms.Where(p => p.TermID == termId).Select(m => m.Name).FirstOrDefault(); reportVm.subjectList = GetSubjects(GetStudentClassRoom(studentId).ClassRoom.ClassRoomID, termId, studentId); return(reportVm); }
public ReportVM getReportVM(int classRoomId, int studentId, int termId) { var db = new ApplicationDbContext(); var report = new ReportVM(); var getStudentDetails = db.students.Where(f => f.StID == studentId).FirstOrDefault(); report.StudentName = getStudentDetails.StudentName; report.StudentSurname = getStudentDetails.StudentSurname; report.GradeName = db.ClassRooms.Where(d => d.ClassRoomID == classRoomId).Select(g => g.GradeName).FirstOrDefault(); var subjectList = new List <SubjectVM>(); var getSubjectList = db.Subjects.Where(y => y.ClassRoomID == classRoomId).ToList(); foreach (var subject in getSubjectList) { var subjectDetails = new SubjectVM(); subjectDetails.SubjectName = subject.SubjectName; subjectDetails.Mark = getSubjectTotal(subject.SubjectID, termId, studentId); subjectDetails.Average = getSubjectAverage(subject.SubjectID, termId, classRoomId); subjectDetails.Comment = getComment(subjectDetails.Mark); subjectList.Add(subjectDetails); } report.subjectList = subjectList; return(report); }