public static ExamVM ExamToExamVM(Exam exam) { var examsRepo = new ExamsRepository(); var examVM = new ExamVM { ExamId = exam.ExamId, CourseId = exam.CourseId, StudentId = exam.StudentId, Date = exam.Date, Grade = (exam.Grade.HasValue) ? Math.Round((double)exam.Grade, 2).ToString("F2") : "absent", Course = examsRepo.GetBasicCourseDetails(exam.ExamId), Student = examsRepo.GetStudentDetails(exam.ExamId) }; return(examVM); }
// GET: Exams/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Exam exam = examsRepo.GetById(id.Value); if (exam == null) { return(HttpNotFound()); } var examVM = ExamMap.ExamToExamVM(exam); examVM.Course = examsRepo.GetBasicCourseDetails(examVM.ExamId); examVM.Student = examsRepo.GetStudentDetails(examVM.ExamId); return(View(examVM)); }