示例#1
0
        public LevelModel Get(long id)
        {
            if (id <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(id));
            }
            var entity = _levelRepository.Get(id);

            return(Mapper.Map <LevelModel>(entity));
        }
示例#2
0
        public CourseDetailViewModel GetCourseDetail(CourseDetailRequestModel requestModel)
        {
            Course course = _courseRepository.Filter(x => x.Id == requestModel.Id).FirstOrDefault();

            if (course != null)
            {
                ILevelReposiroty   levelReposiroty = new LevelRepository(new VtaDbContext());
                IQueryable <Level> levels          = requestModel.GetOrderedData(levelReposiroty.Get()).Include(x => x.Contents);
                if (levels != null)
                {
                    CourseDetailViewModel detailViewModel = new CourseDetailViewModel
                    {
                        CourseViewModel = new CourseViewModel(course),
                        Levels          = levels.ToList().Select(x => new LevelDetailViewModel(x)).ToList()
                    };
                    return(detailViewModel);
                }
            }

            return(null);
        }