Exemplo n.º 1
0
 public SearchHeadwordRowNumberWork(BookViewRepository bookRepository, CategoryRepository categoryRepository,
                                    HeadwordRowNumberSearchRequestContract request, int userId, ProjectTypeEnum projectType, IMapper mapper) : base(bookRepository)
 {
     m_bookRepository     = bookRepository;
     m_categoryRepository = categoryRepository;
     m_request            = request;
     m_userId             = userId;
     m_projectType        = projectType;
     m_mapper             = mapper;
 }
Exemplo n.º 2
0
        public ActionResult <long> SearchHeadwordRowNumber([FromBody] HeadwordRowNumberSearchRequestContract request, [FromQuery] ProjectTypeContract?projectType)
        {
            if (projectType == null)
            {
                return(Error($"Required parameter {nameof(projectType)} is not specified"));
            }

            var result = m_bookManager.SearchHeadwordRowNumber(request, projectType.Value);

            return(result);
        }
Exemplo n.º 3
0
        public long SearchHeadwordRowNumber(HeadwordRowNumberSearchRequestContract request, ProjectTypeContract projectType)
        {
            var userId          = m_authorizationManager.GetCurrentUserId();
            var projectTypeEnum = m_mapper.Map <ProjectTypeEnum>(projectType);

            if (request.Category.BookType == null)
            {
                throw new MainServiceException(MainServiceErrorCode.NullBookTypeNotSupported, "Null value of BookType is not supported");
            }

            var searchHeadwordRowNumberWork =
                new SearchHeadwordRowNumberWork(m_bookRepository, m_categoryRepository, request, userId, projectTypeEnum, m_mapper);
            var result = searchHeadwordRowNumberWork.Execute();

            return(result);
        }
Exemplo n.º 4
0
        public long SearchHeadwordRowNumber(HeadwordRowNumberSearchRequestContract request, ProjectTypeContract projectType)
        {
            try
            {
                var result = m_client.Post <long>($"headword/search-row-number?projectType={projectType}", request);
                return(result);
            }
            catch (HttpRequestException e)
            {
                if (m_logger.IsErrorEnabled())
                {
                    m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e);
                }

                throw;
            }
        }
Exemplo n.º 5
0
        public ActionResult GetHeadwordPageNumber(IList <int> selectedCategoryIds, IList <long> selectedBookIds, string query, int pageSize)
        {
            var request = new HeadwordRowNumberSearchRequestContract
            {
                Query    = query,
                Category = new SelectedCategoryCriteriaContract
                {
                    BookType            = AreaBookType,
                    SelectedBookIds     = selectedBookIds,
                    SelectedCategoryIds = selectedCategoryIds,
                }
            };
            var client    = GetBookClient();
            var rowNumber = client.SearchHeadwordRowNumber(request, GetDefaultProjectType());

            var resultPageNumber = (rowNumber - 1) / pageSize + 1;

            return(Json(resultPageNumber));
        }