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); }
protected virtual async Task Create(QuestionCategoryDto input) { QuestionCategory questionCategoryDto = MappingProfile.MappingConfigurationSetups().Map <QuestionCategory>(input); _context.QuestionCategory.Add(questionCategoryDto); await _context.SaveChangesAsync(); }
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(); } }
public async Task CreateOrEditQuestionCategory(QuestionCategoryDto input) { if (input.Id == null || input.Id == 0) { await Create(input); } else { await Update(input); } }
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()); }
public List <QuestionCategoryDto> GetAllQuestionCategory(QuestionCategoryDto input) { return(_unitOfWork.QuestionCategorys.GetAllQuestionCategory(input)); }
public async Task GetQuestionCategoryForEdit(QuestionCategoryDto input) { await _unitOfWork.QuestionCategorys.GetQuestionCategoryForEdit(input); }
public async Task CreateOrEditQuestionCategory(QuestionCategoryDto input) { await _unitOfWork.QuestionCategorys.CreateOrEditQuestionCategory(input); }