public async Task SearchModules_Call()
        {
            //--------------    Arrange     -------------
            CommonArrangements();
            var searchRequest = new ModuleSearchRequest();

            //--------------    Act     -------------
            var resp = await moduleService.SearchModulesAsync(searchRequest);

            //--------------    Assert     -------------

            A.CallTo(() => _moduleDataAccess.ListPagedAsync(null, 0, 0, null, null)).WithAnyArguments().MustHaveHappened();
        }
        public async Task <IActionResult> GetListJson(JqGridRequest request, ModuleSearchRequest searchRequest)
        {
            var data = await _moduleService.GetPageListBykeyword(searchRequest.ParentId, searchRequest.KeyWord, searchRequest.Condition);

            var            dtos     = CrudDtoMapper.MapEntityToDtos(data);
            JqGridResponse response = new JqGridResponse();

            foreach (ModuleViewModel userInput in dtos)
            {
                response.Records.Add(new JqGridRecord(Convert.ToString(userInput.Id), userInput));
            }

            response.Reader.RepeatItems = false;
            return(new JqGridJsonResult(response));
        }
Example #3
0
        public async Task <ResponseDTO <PagedList <ModuleDTO> > > SearchModulesAsync(ModuleSearchRequest search)
        {
            Expression <Func <ModuleDTO, bool> > queryFilter = c => true;

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

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

            if (search.OnlyParents != null && search.OnlyParents == true)
            {
                queryFilter = queryFilter.And(p => p.Url == null);
            }

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

            Expression <Func <ModuleDTO, object> > expressionModuleCode = p => p.Code;
            List <OrderExpression <ModuleDTO> >    orderExpressions     = new List <OrderExpression <ModuleDTO> >();

            orderExpressions.Add(new OrderExpression <ModuleDTO>(OrderType.Asc, expressionModuleCode));

            var module = await _moduleDataAcces.ListPagedAsync(queryFilter, search.Page, search.PageSize, orderExpressions.ToArray());

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

            return(ResponseBuilder.Correct(pagedResult));
        }
        public async Task <ResponseDTO <PagedList <ModuleDTO> > > Search([FromUri] ModuleSearchRequest search)
        {
            var resp = await _modulesApplicationService.SearchModulesAsync(search);

            return(resp);
        }