public EnrollmentViewModel Create(Enrollment entity) { _enrollmentRepository.Add(entity); var enrollment = _enrollmentRepository .Get <Student>( e => e.StudentId == entity.StudentId ); enrollment = _enrollmentRepository .Get <Course>( e => e.CourseId == entity.CourseId ); return(new EnrollmentViewModel() { Id = enrollment.Id, StudentId = enrollment.StudentId, CourseId = enrollment.CourseId, Student = enrollment.Student, Course = enrollment.Course }); }