コード例 #1
0
        public new QueryResult<CommoditySupplier> Query(QueryBase query)
        {
            var  q= query as QueryCommoditySupplier;

            IQueryable<tblCostCentre> locationQuery;
            if(q.ShowInactive)
               locationQuery = _ctx.tblCostCentre.Where(s=>s.CostCentreType==(int)CostCentreType.CommoditySupplier && (s.IM_Status == (int)EntityStatus.Active || s.IM_Status==(int)EntityStatus.Inactive)).AsQueryable();
            else
                locationQuery = _ctx.tblCostCentre.Where(s => s.CostCentreType == (int)CostCentreType.CommoditySupplier && s.IM_Status == (int)EntityStatus.Active).AsQueryable();

            var queryResult = new QueryResult<CommoditySupplier>();
            if (!string.IsNullOrWhiteSpace(q.Name))
            {
                locationQuery = locationQuery
                    .Where(s => s.Name.ToLower().Contains(q.Name.ToLower()) || s.Cost_Centre_Code.ToLower().Contains(q.Name.ToLower()));
            }
            
            queryResult.Count = locationQuery.Count();
            locationQuery = locationQuery.OrderBy(s => s.Name).ThenBy(s=>s.Cost_Centre_Code);
            if (q.Skip.HasValue && q.Take.HasValue)
                locationQuery = locationQuery.Skip(q.Skip.Value).Take(q.Take.Value);
            var result = locationQuery.ToList();
            queryResult.Data = result.Select(Map).OfType<CommoditySupplier>().ToList();
            q.ShowInactive = false;
            return queryResult;
        }
コード例 #2
0
 public QueryResult<ListVatClassViewModel> Query(QueryBase query)
 {
     var queryResult = _vatClassRepository.Query(query);
     var result = new QueryResult<ListVatClassViewModel>();
     result.Count = queryResult.Count;
     result.Data = queryResult.Data.Select(Map).ToList();
     return result;
 }