Esempio n. 1
0
        public async Task SearchDispatchingPartyAsync_PagedList_in_repository()
        {
            var bus    = A.Fake <IBus>();
            var mapper = A.Fake <IMapper>();
            var repo   = A.Fake <IQueryDataAccess <DispatchingPartyDTO> >();

            var appService = new DispatchingPartyApplicationService(bus, repo, mapper);
            var page       = 1;
            var pageSize   = 10;


            var request = new DispatchingPartySearchRequest()
            {
                Name = "DOW", Page = page, PageSize = pageSize
            };

            A.CallTo(() => repo.ListPagedAsync(null, 0, 0, null, null))
            .WithAnyArguments().Returns(Task.FromResult(new Query.Common.PagedList <DispatchingPartyDTO>()));

            //Act
            var resp = await appService.SearchDispatchingPartyAsync(request);

            //Assert
            Assert.NotNull(resp);
            A.CallTo(() => repo.ListPagedAsync(null, 0, 0, null, null)).WithAnyArguments().MustHaveHappened(Repeated.NoMoreThan.Once);
        }
Esempio n. 2
0
        public async Task <ResponseDTO <PagedList <DispatchingPartyDTO> > > Search([FromUri] DispatchingPartySearchRequest search)
        {
            var resp = await _DispatchingPartyApplicationService.SearchDispatchingPartyAsync(search);

            return(resp);
        }
Esempio n. 3
0
        public async Task <ResponseDTO <PagedList <DispatchingPartyDTO> > > SearchDispatchingPartyAsync(DispatchingPartySearchRequest search)
        {
            Expression <Func <DispatchingPartyDTO, bool> > queryFilter = c => c.RowStatus;

            if (search.DispatchingPartyId > 0)
            {
                queryFilter = queryFilter.And(p => p.DispatchingPartyId == search.DispatchingPartyId);
            }

            if (!string.IsNullOrEmpty(search.Code))
            {
                queryFilter = queryFilter.And(p => p.Code.Contains(search.Code));
            }

            if (!string.IsNullOrEmpty(search.Name))
            {
                queryFilter = queryFilter.And(p => p.Code.Contains(search.Name));
            }

            var DispatchingParty = await _DispatchingPartyDataAccess.ListPagedAsync(queryFilter, search.Page, search.PageSize);

            var pagedResult = new PagedList <DispatchingPartyDTO>()
            {
                Items    = DispatchingParty.Items,
                PageSize = DispatchingParty.PageSize,
                Page     = DispatchingParty.Page,
                Total    = DispatchingParty.Total
            };

            return(ResponseBuilder.Correct(pagedResult));
        }