public async Task GetMandatoryListDataSucess() { MandatoryListSearchViewModel criteria = new MandatoryListSearchViewModel(); var response = await _mandatoryListController.Search(criteria); Assert.NotNull(response); }
public async Task ShouldSearchSuccess() { MandatoryListSearchViewModel criteria = new MandatoryListSearchViewModel(); mandatoryListQueries.Setup(m => m.Search(It.IsAny <MandatoryListSearchViewModel>())) .Returns(() => { return(Task.FromResult <QueryResult <MandatoryListIndexViewModel> >(new MandatoryListDefault().GetMandatoryListIndexViewModelModel())); }); var result = await _sut.Search(criteria); Assert.NotNull(result); }
public Task <QueryResult <MandatoryListIndexViewModel> > Search(MandatoryListSearchViewModel criteria) { return(_dbContext.MandatoryLists .Where(a => a.IsActive == true) .WhereIf(!String.IsNullOrEmpty(criteria.DivisionCode), a => a.DivisionCode == criteria.DivisionCode) .WhereIf(!String.IsNullOrEmpty(criteria.DivisionName), a => a.DivisionNameAr.Contains(criteria.DivisionName)) .WhereIf(criteria.StatusId.HasValue, a => a.StatusId == criteria.StatusId) .WhereIf(!String.IsNullOrEmpty(criteria.CSICode), a => a.Products.Any(a => a.CSICode.Contains(criteria.CSICode) && a.IsActive == true)) .WhereIf(!String.IsNullOrEmpty(criteria.ProductNameAr), a => a.Products.Any(a => a.NameAr.Contains(criteria.ProductNameAr) && a.IsActive == true)) .WhereIf(criteria.PriceCelling.HasValue, a => a.Products.Any(a => a.PriceCelling == criteria.PriceCelling.Value && a.IsActive == true)) .OrderBy(x => x.Id) .SortBy(criteria.Sort, criteria.SortDirection) .ProjectTo <MandatoryListIndexViewModel>(_mapper.ConfigurationProvider) .ToQueryResult(criteria.PageNumber, criteria.PageSize)); }
public async Task <IActionResult> IndexPagingAsync(MandatoryListSearchViewModel searchViewModel) { try { var queryResult = await _apiClient.GetQueryResultAsync <MandatoryListIndexViewModel>("MandatoryList/Search", searchViewModel.ToDictionary()); return(Json(new PaginationModel(queryResult.Items, queryResult.TotalCount, queryResult.PageSize, queryResult.PageNumber, null))); } catch (AuthorizationException ex) { throw ex; } catch (BusinessRuleException ex) { return(JsonErrorMessage(ex.Message)); } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); return(JsonErrorMessage(Resources.TenderResources.ErrorMessages.UnexpectedError)); } }
public async Task <QueryResult <MandatoryListIndexViewModel> > Search(MandatoryListSearchViewModel criteria) { return(await _mandatoryListAppService.Search(criteria)); }
public Task <QueryResult <MandatoryListIndexViewModel> > Search(MandatoryListSearchViewModel criteria) { return(_mandatoryListQueries.Search(criteria)); }