public async Task <CreateOrUpdateCourseDto> GetForEdit(NullableIdDto <long> input)
        {
            var output = new CreateOrUpdateCourseDto();

            if (input.Id.HasValue)
            {
                var entity = await _courseManager.QueryAsNoTracking
                             .Where(e => e.Id == input.Id.Value)
                             .Include(e => e.CourseCategories)
                             .FirstOrDefaultAsync();

                if (entity == null)
                {
                    throw new UserFriendlyException("抱歉!未找到对应课程");
                }
                output.Entity = ObjectMapper.Map <CourseDto>(entity);
                //output.CategoryIds = entity.CourseCategories.Select(e => e.CourseCategoryId).ToList();
                output.CategoryIds = await _courseToCourseCategoryManager.GetCateByCourseId(entity.Id)
                                     .ToListAsync();
            }
            else
            {
                output.Entity = new CourseDto();
            }

            output.CourseStateEnum = _enumExtensionsAppService
                                     .GetEntityDoubleStringKeyValueList <CourseStateEnum>();
            output.CourseDisplayTypeEnum = _enumExtensionsAppService.GetEntityDoubleStringKeyValueList <CourseTypeEnum>();
            output.CourseVideoTypeEnum   = _enumExtensionsAppService.GetEntityDoubleStringKeyValueList <CourseVideoTypeEnum>();

            return(output);
        }
        public async Task <GetPostForEditOutput> GetForEdit(NullableIdDto <Guid> input)
        {
            var         output = new GetPostForEditOutput();
            PostEditDto editDto;

            if (input.Id.HasValue)
            {
                var entity = await _postRepository.GetAsync(input.Id.Value);

                editDto = ObjectMapper.Map <PostEditDto>(entity);
                var tagsList = await GetTagsOfPost(entity.Id);

                if (tagsList.Count > 0)
                {
                    editDto.TagIds = tagsList.Select(t => t.Id).ToList();
                }
            }
            else
            {
                editDto = new PostEditDto();
            }

            output.PostTypeTypeEnum = _enumExtensionsAppService.GetEntityDoubleStringKeyValueList <PostType>();

            output.Post = editDto;
            return(output);
        }
 private IEnumerable <ComboboxItemDtoT <string> > GetEnumForCombobox <TEnum>()
 {
     return(_enumExtensionsAppService
            .GetEntityDoubleStringKeyValueList <TEnum>()
            .Select(o =>
     {
         return new ComboboxItemDtoT <string>()
         {
             DisplayText = o.Key,
             Value = o.Value
         };
     }));
 }
        public async Task <GetDropdownListForEditOutput> GetForEdit(string input)
        {
            var output = new GetDropdownListForEditOutput();
            DropdownListEditDto editDto;

            if (string.IsNullOrEmpty(input))
            {
                var entity = await _dropdownListRepository.GetAsync(input);

                editDto = ObjectMapper.Map <DropdownListEditDto>(entity);
            }
            else
            {
                editDto = new DropdownListEditDto();
            }

            output.DropdownTypeTypeEnum = _enumExtensionsAppService.GetEntityDoubleStringKeyValueList <DropdownType>();

            output.DropdownList = editDto;
            return(output);
        }