Пример #1
0
        public DataTableResult <CustomUserPlan> SearchUserPlans(DataTableAjaxPostModel model)
        {
            var searchBy = (model.search != null) ? model.search.value : null;
            var take     = model.length;
            var skip     = model.start;

            string sortBy  = "";
            bool   sortDir = true;

            if (model.order != null)
            {
                // in this example we just default sort on the 1st column
                sortBy  = model.columns[model.order[0].column].data;
                sortDir = model.order[0].dir.ToLower() == "asc";
            }

            // search the dbase taking into consideration table sorting and paging
            TittleUserServices _Service             = new TittleUserServices();
            DataTableResult <CustomUserPlan> result = new Models.DataTableResult <CustomUserPlan>();
            int filteredResultsCount = 0;
            int totalResultsCount    = 0;

            result.result = _Service.GetUserPlans(searchBy, model.promoCode, model.plan, model.fromDate, model.toDate, take, skip, sortBy, sortDir, out filteredResultsCount, out totalResultsCount);
            result.filteredResultsCount = filteredResultsCount;
            result.totalResultsCount    = totalResultsCount;
            if (result.result == null)
            {
                // empty collection...
                return(new DataTableResult <CustomUserPlan>());
            }
            return(result);
        }