public async Task <IWrappedResponse> Search(LoadCarrierReceiptsSearchRequest request) { var cmd = ServiceCommand <LoadCarrierReceipt, Rules.LoadCarrierReceipts.Search.MainRule> .Create(_serviceProvider) .When(new Rules.LoadCarrierReceipts.Search.MainRule(request)) .Then(SearchAction); return(await cmd.Execute()); }
public async Task <LoadResult> Get(DataSourceLoadOptions loadOptions, [FromQuery] LoadCarrierReceiptsSearchRequest request) { var response = await _loadCarrierReceiptsService.Search(request) as WrappedResponse <IQueryable <LoadCarrierReceipt> >; return(await DataSourceLoader.LoadAsync(response?.Data, loadOptions)); }
public MainRule(LoadCarrierReceiptsSearchRequest request, IRule parentRule = null) { // Create Context Context = new ContextModel(request, this); ParentRule = parentRule; }
private IQueryable <Olma.LoadCarrierReceipt> BuildLoadCarrierReceiptSearchQuery(LoadCarrierReceiptsSearchRequest request) { var query = _olmaLoadCarrierReceiptRepo.FindAll() .AsNoTracking(); if (request.Type != null) { query = query.Where(v => request.Type.Contains(v.Type)); } if (!string.IsNullOrEmpty(request.DocumentNumber)) { query = query.Where(v => v.Document.Number.Contains(request.DocumentNumber)); //TODO compare as SQL LIKE } if (request.LoadCarrierTypes?.Count > 0) { query = query.Where(i => i.Positions.Any(p => request.LoadCarrierTypes.Contains(p.LoadCarrier.TypeId))); } if (request.IssueDateFrom != null) { query = query.Where(i => i.CreatedAt >= request.IssueDateFrom); } if (request.IssueDateTo != null) { query = query.Where(i => i.CreatedAt >= request.IssueDateTo); } return(query); }