Beispiel #1
0
        public async Task SearchEquipment_Call_PagedList_in_repository()
        {
            var request = new EquipmentSearchRequest()
            {
                EquipmentNo = "PAPU0000004", Page = 1, PageSize = 20
            };

            A.CallTo(() => repo.ListPagedAsync(null, 0, 0, null, null)).WithAnyArguments().Returns(Task.FromResult(new Query.Common.PagedList <EquipmentDTO>()
            {
                PageSize = 1, Page = 1, Total = 1, Items = new List <EquipmentDTO>()
                {
                    new EquipmentDTO()
                    {
                        EquipmentId = 666
                    }
                }
            }));

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

            //Assert

            Assert.NotNull(resp);
            // A.CallTo(() => repo.ListPagedAsync(null, 0, 0, null, null)).WithAnyArguments().MustHaveHappened();
            Assert.AreEqual(resp.Messages.First().Key, "Info");
        }
        public async Task <ResponseDTO <PagedList <EquipmentDTO> > > Search([FromUri] EquipmentSearchRequest search)
        {
            var resp = await _EquipmentApplicationService.SearchEquipmentAsync(search);

            return(resp);
        }
Beispiel #3
0
        public async Task <ResponseDTO <PagedList <EquipmentDTO> > > SearchEquipmentAsync(EquipmentSearchRequest search)
        {
            Expression <Func <EquipmentDTO, bool> > queryFilter = c => c.RowStatus;

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

            var equipment = await _equipmentDataAccess.ListPagedAsync(queryFilter, search.Page, search.PageSize);

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

            var response = ResponseBuilder.Correct(pagedResult);

            response.Messages = new List <ApplicationMessage>();
            response.Messages.Add(new ApplicationMessage()
            {
                Key     = "Info",
                Message = !pagedResult.Items.Any() ? "No records found for this request" : ""
            });

            return(response);
        }