示例#1
0
        public void SearchForConcepts_Fetches_Concepts_When_Query_Is_Specified()
        {
            A.CallTo(() => ConceptRepository.SearchForConcepts(A <ConceptSearchQuery> ._)).Returns(new List <Concept>());
            var results = Service.SearchForConcepts(new ConceptSearchQuery());

            A.CallTo(() => ConceptRepository.GetAll(BaseListQuery)).Returns(new List <Concept>());
            A.CallTo(() => ConceptRepository.SearchForConcepts(A <ConceptSearchQuery> ._)).Returns(new List <Concept>());

            Assert.IsType <PagingDTO <ConceptDto> >(results.Data);
        }
示例#2
0
        public Response GetAllConcepts(BaseListQuery query)
        {
            try
            {
                var concepts      = _conceptRepository.GetAll(query);
                var totalItems    = 0;
                var numberOfPages = 0;

                try
                {
                    totalItems    = concepts.FirstOrDefault().TotalItems;
                    numberOfPages = concepts.FirstOrDefault().NumberOfPages;
                }
                catch { }

                var res = new PagingDTO <ConceptDto>(
                    Mapper.Map <List <ConceptDto> >(concepts),
                    query,
                    UrlHelper.Action("GetAll", "Concept", query),
                    numberOfPages,
                    totalItems);

                return(new Response
                {
                    Data = res
                });
            }
            catch (Exception e)
            {
                return(null);
            }
        }