Пример #1
0
        public List <QuestionCategoryDto> GetAllQuestionCategory(QuestionCategoryDto input)
        {
            var query = (from questionCategory in _context.QuestionCategory.ToList()
                         select new QuestionCategoryDto
            {
                Name = questionCategory.Name,
                Id = questionCategory.Id,
                DateCreated = questionCategory.DateCreated,
                Status = questionCategory.Status,
                UserId = questionCategory.UserId
            }).ToList().Skip((input.PagedResultDto.Page - 1) * input.PagedResultDto.SkipCount).Take(input.PagedResultDto.MaxResultCount);

            // Map Records
            List <QuestionCategoryDto> roleDto = MappingProfile.MappingConfigurationSetups().Map <List <QuestionCategoryDto> >(query);

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

            // Apply search
            if (!string.IsNullOrEmpty(input.PagedResultDto.Search))
            {
                roleDto = roleDto.Where(p => p.Status != null && p.Status.ToLower().ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                        p.Name != null && p.Name.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower()) ||
                                        p.DateCreated != null && p.DateCreated.ToString().ToLower().Contains(input.PagedResultDto.Search.ToLower())
                                        ).ToList();
            }
            return(roleDto);
        }
Пример #2
0
        protected virtual async Task Create(QuestionCategoryDto input)
        {
            QuestionCategory questionCategoryDto = MappingProfile.MappingConfigurationSetups().Map <QuestionCategory>(input);

            _context.QuestionCategory.Add(questionCategoryDto);
            await _context.SaveChangesAsync();
        }
Пример #3
0
        protected virtual async Task Update(QuestionCategoryDto input)
        {
            var questionCategory = await _context.QuestionCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (questionCategory != null)
            {
                QuestionCategory questionCategoryDto = MappingProfile.MappingConfigurationSetups().Map <QuestionCategory>(input);
                _context.QuestionCategory.Update(questionCategoryDto);
                await _context.SaveChangesAsync();
            }
        }
Пример #4
0
 public async Task CreateOrEditQuestionCategory(QuestionCategoryDto input)
 {
     if (input.Id == null || input.Id == 0)
     {
         await Create(input);
     }
     else
     {
         await Update(input);
     }
 }
Пример #5
0
        public async Task <QuestionCategoryDto> GetQuestionCategoryForEdit(QuestionCategoryDto input)
        {
            var questionCategory = await _context.QuestionCategory.Where(x => x.Id == input.Id).FirstOrDefaultAsync();

            if (questionCategory != null)
            {
                QuestionCategory questionCategoryDto = MappingProfile.MappingConfigurationSetups().Map <QuestionCategory>(input);
                _context.QuestionCategory.Update(questionCategoryDto);
                await _context.SaveChangesAsync();

                return(MappingProfile.MappingConfigurationSetups().Map <QuestionCategoryDto>(questionCategoryDto));
            }
            return(new QuestionCategoryDto());
        }
Пример #6
0
 public List <QuestionCategoryDto> GetAllQuestionCategory(QuestionCategoryDto input)
 {
     return(_unitOfWork.QuestionCategorys.GetAllQuestionCategory(input));
 }
Пример #7
0
 public async Task GetQuestionCategoryForEdit(QuestionCategoryDto input)
 {
     await _unitOfWork.QuestionCategorys.GetQuestionCategoryForEdit(input);
 }
Пример #8
0
 public async Task CreateOrEditQuestionCategory(QuestionCategoryDto input)
 {
     await _unitOfWork.QuestionCategorys.CreateOrEditQuestionCategory(input);
 }