public ListOfCategoriesAdminVm GetCategoriesForAdmin()
        {
            var categories = _categoryAndQuestionForAdminRepo.GetCategoriesForAdmin()
                             .ProjectTo <CategoryToListAdminVm>(_mapper.ConfigurationProvider).ToList();
            var categoriesToAdmin = new ListOfCategoriesAdminVm()
            {
                Categories = categories
            };

            return(categoriesToAdmin);
        }
        public ListOfQuestionAdminVm ShowQuestionsToAdmin(int pageSize, int pageNo, string searchString, int categoryId)
        {
            var questions = new List <QuestionToListAdminVm>();

            if (categoryId == 0)
            {
                questions = _categoryAndQuestionForAdminRepo.ShowQuestions().Where(p => p.QuestionText.StartsWith(searchString))
                            .ProjectTo <QuestionToListAdminVm>(_mapper.ConfigurationProvider).ToList();
            }
            else
            {
                questions = _categoryAndQuestionForAdminRepo.ShowQuestions().Where(p => p.QuestionText.StartsWith(searchString) &&
                                                                                   p.CategoryId == categoryId).ProjectTo <QuestionToListAdminVm>(_mapper.ConfigurationProvider).ToList();
            }
            var sortedQuestionsByIsAccepted = questions.OrderBy(i => i.IsAccepted).ToList();
            var questionsToShow             = sortedQuestionsByIsAccepted.Skip(pageSize * (pageNo - 1)).Take(pageSize).ToList();
            var categories = _categoryAndQuestionForAdminRepo.GetCategoriesForAdmin().ProjectTo <CategoryToListAdminVm>
                                 (_mapper.ConfigurationProvider).ToList();
            CategoryToListAdminVm categoryToList = new CategoryToListAdminVm()
            {
                Id = 0, Name = "Nie wybieram żadnej kategorii"
            };

            categories.Add(categoryToList);
            ListOfCategoriesAdminVm listOfCategories = new ListOfCategoriesAdminVm()
            {
                Categories = categories
            };
            var listOfQuestion = new ListOfQuestionAdminVm()
            {
                Questions    = questionsToShow,
                CurrentPage  = pageNo,
                PageSize     = pageSize,
                SearchString = searchString,
                Count        = questions.Count,
                Categories   = listOfCategories,
                CategoryId   = categoryId
            };

            return(listOfQuestion);
        }