Exemplo n.º 1
0
        public async Task <ApiRequestResult> AddAsync(TopicCategoryDto dto)
        {
            var command = dto.EntityMap <TopicCategoryDto, TopicCategory>();
            await _topicCategoryRepository.AddAsync(command);

            return(ApiRequestResult.Success("添加成功"));
        }
Exemplo n.º 2
0
        public List <TopicCategoryDto> GetAllTopicCategory(TopicCategoryDto input)
        {
            var query = (from topic in _context.TopicCategory.ToList()
                         select new TopicCategoryDto
            {
                Id = topic.Id,
                DateCreated = topic.DateCreated,
                Status = topic.Status,
                UserId = topic.UserId,
                CloudFolder = topic.CloudFolder,
                CloudKey = topic.CloudKey,
                ImagePath = topic.ImagePath,
                Name = topic.Name,
            }).ToList().Skip((input.PagedResultDto.Page - 1) * input.PagedResultDto.SkipCount).Take(input.PagedResultDto.MaxResultCount);

            // Map Records
            List <TopicCategoryDto> ratingDto = MappingProfile.MappingConfigurationSetups().Map <List <TopicCategoryDto> >(query);

            //Apply Sort
            ratingDto = Sort(input.PagedResultDto.Sort, input.PagedResultDto.SortOrder, ratingDto);

            // Apply search
            if (!string.IsNullOrEmpty(input.PagedResultDto.Search))
            {
                ratingDto = ratingDto.Where(p => p.Status != null && p.Status.ToLower().ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                            p.CloudKey != null && p.CloudKey.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                            p.DateCreated != null && p.DateCreated.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                            p.CloudFolder != null && p.CloudFolder.ToString().ToLower().ToString().Contains(input.PagedResultDto.Search.ToLower()) ||
                                            p.ImagePath != null && p.ImagePath.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                            p.Name != null && p.Name.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower())
                                            ).ToList();
            }
            return(ratingDto);
        }
Exemplo n.º 3
0
        protected virtual async Task Create(TopicCategoryDto input)
        {
            TopicCategory topicCategoryDto = MappingProfile.MappingConfigurationSetups().Map <TopicCategory>(input);

            _context.TopicCategory.Add(topicCategoryDto);
            await _context.SaveChangesAsync();
        }
Exemplo n.º 4
0
        public async Task <ApiRequestResult> UpdateAsync(TopicCategoryDto dto)
        {
            var entity = await _topicCategoryRepository.GetAsync(dto.Id.Value);

            var newEntity = dto.EntityMap(entity);
            await _topicCategoryRepository.UpdateAsync(newEntity);

            return(ApiRequestResult.Success("修改成功"));
        }
Exemplo n.º 5
0
        protected virtual async Task Update(TopicCategoryDto input)
        {
            var users = await _context.TopicCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (users != null)
            {
                TopicCategory topicCategoryDto = MappingProfile.MappingConfigurationSetups().Map <TopicCategory>(input);
                _context.TopicCategory.Update(topicCategoryDto);
                await _context.SaveChangesAsync();
            }
        }
Exemplo n.º 6
0
 public async Task CreateOrEditTopicCategory(TopicCategoryDto input)
 {
     if (input.Id == null || input.Id == 0)
     {
         await Create(input);
     }
     else
     {
         await Update(input);
     }
 }
Exemplo n.º 7
0
        public async Task <TopicCategoryDto> GetTopicCategoryForEdit(TopicCategoryDto input)
        {
            var topics = await _context.TopicCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (topics != null)
            {
                TopicCategory topicCategoryDto = MappingProfile.MappingConfigurationSetups().Map <TopicCategory>(input);
                _context.TopicCategory.Update(topicCategoryDto);
                await _context.SaveChangesAsync();

                return(MappingProfile.MappingConfigurationSetups().Map <TopicCategoryDto>(topicCategoryDto));
            }
            return(new TopicCategoryDto());
        }
Exemplo n.º 8
0
 public List <TopicCategoryDto> GetAllTopicCategory(TopicCategoryDto input)
 {
     return(_unitOfWork.TopicCategorys.GetAllTopicCategory(input));
 }
Exemplo n.º 9
0
 public async Task GetTopicCategoryForEdit(TopicCategoryDto input)
 {
     await _unitOfWork.TopicCategorys.GetTopicCategoryForEdit(input);
 }
Exemplo n.º 10
0
 public async Task CreateOrEditTopicCategory(TopicCategoryDto input)
 {
     await _unitOfWork.TopicCategorys.CreateOrEditTopicCategory(input);
 }