Esempio n. 1
0
        public async Task <ExamDetailsModel> GetExamDetails(int examId)
        {
            try
            {
                var result      = new ExamDetailsModel();
                var examDetails = await _examsRepository.GetExamDetails(examId);

                if (examDetails != null)
                {
                    result.ExamDetails = _mapper.Map <ExamModel>(examDetails);
                    if (examDetails.StudentExams != null && examDetails.StudentExams.Count > 0)
                    {
                        foreach (var item in examDetails.StudentExams)
                        {
                            result.ExamStudents.Add(_mapper.Map <StudentDetails>(item.Student));
                        }
                    }
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }