public ViewForExamPdf GenerateExamResultPdf(Guid idExam, Guid IdOpenAnswer) { ViewForExamPdf viewForExamPdf = new ViewForExamPdf(); try { var viewFullinfAbouExam = from e in Database.Exams.GetList() join eo in Database.ExamOpenAnswerByStds.GetList() on e.Id equals eo.ExamId join eq in Database.ExamQuestions.GetList() on e.Id equals eq.ExamId join q in Database.Questions.GetList() on eq.QuestionId equals q.Id join oa in Database.OpenAnswerGivenByStutents.GetList() on eo.OpenAnswerGivenByStutentId equals oa.Id join ser in Database.StudentExamResults.GetList() on eo.StudentExamResultId equals ser.Id join sp in Database.StudentProfiles.GetList() on ser.StudentProfileId equals sp.Id join se in Database.SubjectExams.GetList() on e.Id equals se.ExamId join s in Database.Subjects.GetList() on se.SubjectId equals s.Id join cm in Database.CommentToExamResults.GetList() on ser.Id equals cm.StudentExamResultId into cm_join from cm in cm_join.DefaultIfEmpty() where e.Id == idExam && eo.OpenAnswerGivenByStutentId == IdOpenAnswer select new { StudentExamResultId = eo.StudentExamResultId, Comment = cm == null ?string.Empty : cm.Comment, SubjectName = s.Name, ExamName = e.Name, Runtime = e.Runtime, Answers = oa == null ? string.Empty : oa.Answers, QuestionTitle = q.QuestionTitle, FirstName = sp.FirstName, SecondName = sp.SecondName, StartExam = ser.StartExam, EndtExam = ser.EndtExam, Mark = ser.Mark }; viewForExamPdf = viewFullinfAbouExam.GroupBy(t => t.StudentExamResultId).ToList().Select(qw => new ViewForExamPdf { StudentExamResultId = qw.First().StudentExamResultId, Comment = qw.First().Comment, SubjectName = qw.First().SubjectName, ExamName = qw.First().ExamName, Runtime = qw.First().Runtime, Answers = qw.First().Answers, Questions = string.Join("& ", qw.Select(e => e.QuestionTitle)), FirstName = qw.First().FirstName, SecondName = qw.First().SecondName, StartExam = qw.First().StartExam, EndtExam = qw.First().EndtExam, Mark = qw.First().Mark }).FirstOrDefault(); } catch (Exception ex) { Logger.Log.Error(ex.Message); } return(viewForExamPdf); }
public ActionResult ExamResult(Guid idExam, Guid IdOpenAnswer) { ViewForExamPdf listViewForExamPdf = examCheck.GenerateExamResultPdf(idExam, IdOpenAnswer); //return new PdfResult(listViewForExamPdf, "ExamResult"); return(new ViewAsPdf(listViewForExamPdf)); // return new PdfResult(null, "ExamResult"); // return View(listViewForExamPdf); //return listViewForExamPdf; }