예제 #1
0
        public ActionResult ActFinYearDataSource([FromBody] DataManagerRequest dm, string FinancialYearCode, int?AwpSoCode)
        {
            if (string.IsNullOrEmpty(FinancialYearCode) || FinancialYearCode.Contains("null"))
            {
                FinancialYearCode = null;
            }

            ActFinYearModels obj = new ActFinYearModels(context);

            var         _data = obj.GetAll().Where(a => (a.financial_year_code == FinancialYearCode || FinancialYearCode == null) && (a.awp_so_code == AwpSoCode || AwpSoCode == 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 }));
        }
예제 #2
0
        public ActionResult DataSourceActFinYear([FromBody] DataManagerRequest dm)
        {
            ActFinYearModels obj = new ActFinYearModels(context);
            var _data            = obj.GetAll().OrderByDescending(a => a.financial_year_code).ToList();

            //var _data = context.ViewAwpFinancialYearActivity.AsNoTracking().OrderByDescending(a => a.FinancialYearCode).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 }));
        }