public async Task <ActionResult <CollectionViewModel <Commodity> > > Get( string company, [FromQuery] PagingOptions pagingOptions, [FromQuery] CommoditySearchTerm commoditySearchTerm, [FromQuery] string code = null, [FromQuery] string description = null, [FromQuery] bool includeDeactivated = false, [FromQuery] string viewMode = MasterDataViewMode.Local) { if (!string.IsNullOrEmpty(code)) { commoditySearchTerm.PrincipalCommodity = code; } var commodities = await _commodityRepository.GetAllAsync(viewMode == MasterDataViewMode.Local?company : null, commoditySearchTerm, pagingOptions.Offset, null /*pagingOptions.Limit*/, includeDeactivated, description); var response = new PaginatedCollectionViewModel <Commodity>(pagingOptions.Offset.Value, pagingOptions.Limit.Value, commodities.ToList()); return(Ok(response)); }
public async Task <IEnumerable <Commodity> > GetAllAsync(string companyId, CommoditySearchTerm commoditySearchTerm, int?offset, int?limit, bool includeDeactivated = false, string description = null) { var queryParameters = new DynamicParameters(); queryParameters.Add("@CompanyId", companyId); queryParameters.Add("@PrincipalCommodity", commoditySearchTerm.PrincipalCommodity); queryParameters.Add("@CommodityOrigin", commoditySearchTerm.Part2); queryParameters.Add("@CommodityGrade", commoditySearchTerm.Part3); queryParameters.Add("@CommodityLvl4", commoditySearchTerm.Part4); queryParameters.Add("@CommodityLvl5", commoditySearchTerm.Part5); queryParameters.Add("@offsetRows", offset ?? 0); queryParameters.Add("@fetchRows", limit ?? int.MaxValue); queryParameters.Add("@IncludeDeactivated", includeDeactivated); queryParameters.Add("@Description", description); var commodities = await ExecuteQueryAsync <Commodity>( StoredProcedureNames.GetCommodities, queryParameters); return(commodities); }