Beispiel #1
0
        public ActionResult StrategyDataSource([FromBody] DataManagerRequest dm, string stratissue)
        {
            if (string.IsNullOrEmpty(stratissue) || stratissue.Contains("null"))
            {
                stratissue = null;
            }

            StrategyModels obj = new StrategyModels(context);

            var         _data = obj.GetAll().Where(a => (a.sp_si_code == stratissue || stratissue == null)).ToList();
            IEnumerable data  = _data;
            int         count = _data.Count;

            DataOperations operation = new DataOperations();

            //Performing filtering operation

            if (dm.Where != null)
            {
                data = operation.PerformFiltering(data, dm.Where, "and");
                var filtered = (IEnumerable <object>)data;
                count = filtered.Count();
            }
            //Performing search operation
            if (dm.Search != null)
            {
                data = operation.PerformSearching(data, dm.Search);
                var searched = (IEnumerable <object>)data;
                count = searched.Count();
            }
            //Performing sorting operation
            if (dm.Sorted != null)
            {
                data = operation.PerformSorting(data, dm.Sorted);
            }

            //Performing paging operations
            if (dm.Skip > 0)
            {
                data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take > 0)
            {
                data = operation.PerformTake(data, dm.Take);
            }

            return(Json(new { result = data, count = count }));
        }
Beispiel #2
0
        public ActionResult DataSourceStrategy([FromBody] DataManagerRequest dm)
        {
            //var _data = context.ViewSpActivity.AsNoTracking().Select(a => new
            //{
            //    a.SpStrategyCode,
            //    a.SpSiCode,
            //    a.SpSiIssue,
            //    a.SpSiObjectives,
            //    a.SpStrategyDesc
            //}).Distinct().OrderByDescending(a => a.SpStrategyCode).ToList();

            StrategyModels obj = new StrategyModels(context);
            //var _data = obj.GetAll().OrderByDescending(a => a.sp_strategy_code).ToList();

            var _data = obj.GetAll().Select(a => new
            {
                a.sp_strategy_code,
                a.sp_si_code,
                a.sp_si_issue,
                a.sp_si_objectives,
                a.sp_strategy_desc
            }).OrderByDescending(a => a.sp_strategy_code).ToList();


            IEnumerable data  = _data;
            int         count = _data.Count;


            DataOperations operation = new DataOperations();

            //Performing filtering operation
            if (dm.Where != null)
            {
                data = operation.PerformFiltering(data, dm.Where, "and");
                var filtered = (IEnumerable <object>)data;
                count = filtered.Count();
            }
            //Performing search operation
            if (dm.Search != null)
            {
                data = operation.PerformSearching(data, dm.Search);
                var searched = (IEnumerable <object>)data;
                count = searched.Count();
            }
            //Performing sorting operation
            if (dm.Sorted != null)
            {
                data = operation.PerformSorting(data, dm.Sorted);
            }

            //Performing paging operations
            if (dm.Skip > 0)
            {
                data = operation.PerformSkip(data, dm.Skip);
            }
            if (dm.Take > 0)
            {
                data = operation.PerformTake(data, dm.Take);
            }

            return(Json(new { result = data, count = count }));
        }