コード例 #1
0
ファイル: KpiService.cs プロジェクト: cobianwae/Pear
        public GetKpisResponse GetKpis(GetKpisRequest request)
        {
            int totalRecords;
            var data = SortData(request.Search, request.SortingDictionary, out totalRecords);

            if (request.Take != -1)
            {
                data = data.Skip(request.Skip).Take(request.Take);
            }

            //var kpis = new Queryable<Kpi>();

            /*if (request.Take != 0)
             * {
             *  kpis = DataContext.Kpis.Include(x => x.Pillar).OrderBy(x => x.Id).Skip(request.Skip).Take(request.Take);
             * }
             * else
             * {
             *  kpis = DataContext.Kpis.Include(x => x.Pillar);
             * }
             *
             * if (request.PillarId > 0)
             * {
             *  kpis = kpis.Include(x => x.Pillar).Where(x => x.Pillar.Id == request.PillarId);
             * }*/


            var response = new GetKpisResponse();

            response.TotalRecords = totalRecords;
            response.Kpis         = data.ToList().MapTo <GetKpisResponse.Kpi>();

            return(response);
        }
コード例 #2
0
ファイル: KpiService.cs プロジェクト: yhsantosa/Pear
        public GetKpisResponse GetKpis(GetKpisRequest request)
        {
            IQueryable <Kpi> kpis;

            //var kpis = new Queryable<Kpi>();
            if (request.Take != 0)
            {
                kpis = DataContext.Kpis.Include(x => x.Pillar).OrderBy(x => x.Id).Skip(request.Skip).Take(request.Take);
            }
            else
            {
                kpis = DataContext.Kpis.Include(x => x.Pillar);
            }

            if (request.PillarId > 0)
            {
                kpis = kpis.Include(x => x.Pillar).Where(x => x.Pillar.Id == request.PillarId);
            }

            var response = new GetKpisResponse();

            response.Kpis = kpis.ToList().MapTo <GetKpisResponse.Kpi>();

            return(response);
        }