public CourseInfo GetCourseById(long id) { if (id == 0) { return new CourseInfo() { m_Coacher = new Coacher(), m_CourseCategory = new CourseCategory() } } ; var item = _courseInfoRep.GetById(id); var courseCoacher = _courseCoacherRep.FindBy(x => x.CourseID == id).FirstOrDefault(); item.CoacherID = courseCoacher == null ? 0 : courseCoacher.CoacherID; item.m_CourseCategory = _courseCategoryRep.GetById(item.m_CourseCategoryId); return(item); //var item = _courseInfoRep.GetByIdIncludeEntitys<CourseCategory>(id, x => x.m_CourseCategory); //return item; }
public Coacher GetById(long id) { if (id == 0) { return(new Coacher()); } var item = _coacherRep.GetById(id); var courseCoachers = _courseCoacherRep.FindBy(x => x.CoacherID == id); if (courseCoachers.Any()) { var now = DateTime.Now; var courses = _courseRep.GetMany(x => x.CourseBeginTime <= now && x.CourseEndTime >= now); var cos = from c in courses join b in courseCoachers on c.ID equals b.CourseID select c; item.Courses = cos.ToList(); } return(item); }