public PreExamRespone GetExamRegis(string pid) { var data = repoOnSite.GetExamRegisInfo(pid); if (data.Count() > 0) { var regisInfo = data.FirstOrDefault(); var result = new PreExamRespone { PID = regisInfo.PID, Firstname = regisInfo.FirstName, LastName = regisInfo.LastName, ExamNumber = regisInfo.ExamNumber, Title = regisInfo.Title, SubjectRespones = data.Select(x => new SubjectRespone { SubjectCode = x.SubjectCode, SubjectName = x.SubjectName, }).ToList(), }; return(result); } else { return(null); } }