public StudentParent GetStudentParent(int studentParentId) { var studentParent = db.StudentParentsRepository.GetByID(studentParentId); if (studentParent == null) { logger.Info("StudentParent {@studentParentId} not found", studentParentId); var ex = new StudentParentNotFoundException(string.Format("StudentParent {0} not found", studentParentId)); ex.Data.Add("studentParentId", studentParentId); throw ex; } return(studentParent); }
public StudentParent GetStudentParent(int studentId, int parentId) { StudentUser student = studentsService.Value.GetStudentById(studentId); ParentUser parent = parentsService.Value.GetParentById(parentId); var studentParent = db.StudentParentsRepository.Get(sp => sp.StudentId == studentId && sp.ParentId == parentId).FirstOrDefault(); if (studentParent == null) { logger.Info("Student {@studentId} is not related to Parent {@parentId}", studentId, parentId); var ex = new StudentParentNotFoundException(string.Format("Student {0} is not related to Parent {1}", studentId, parentId)); ex.Data.Add("studentId", studentId); ex.Data.Add("parentId", parentId); throw ex; } return(studentParent); }