Example #1
0
        public ActionResult AccountList(int Mid)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            Session["MarketId"] = Mid;
            var viewModel = GridViewExtension.GetViewModel("accountsGridView");

            if (viewModel == null)
            {
                viewModel = AccountCustomBinding.CreateAccountGridViewModel();
            }

            if (string.IsNullOrEmpty(viewModel.FilterExpression) && ControllerContext.HttpContext.Request.Cookies.AllKeys.Contains("AccountsList"))
            {
                HttpCookie cookie       = this.ControllerContext.HttpContext.Request.Cookies["AccountsList"];
                var        decodedValue = HttpUtility.UrlDecode(cookie.Value);
                var        filterParams = decodedValue
                                          .Split('|')
                                          .ToList();
                var lengthParam = filterParams.Where(x => x.StartsWith("filter")).SingleOrDefault();

                if (!string.IsNullOrEmpty(lengthParam))
                {
                    var index = filterParams.IndexOf(lengthParam);
                    var savedFilterExpression = filterParams[index + 1];
                    viewModel.FilterExpression = savedFilterExpression;
                }

                var pageNo = filterParams.Where(x => x.StartsWith("page")).SingleOrDefault();
                if (!string.IsNullOrEmpty(pageNo))
                {
                    var index                = filterParams.IndexOf(pageNo);
                    var savedPageNo          = filterParams[index];
                    var savedPageSize        = filterParams[index + 1];
                    GridViewPagerState state = new GridViewPagerState();
                    state.PageIndex = Convert.ToInt32(string.Join("", savedPageNo.ToCharArray().Where(Char.IsDigit))) - 1;
                    state.PageSize  = Convert.ToInt32(string.Join("", savedPageSize.ToCharArray().Where(Char.IsDigit)));
                    viewModel.Pager.Assign(state);
                }
            }

            return(AccountGridActionCore(viewModel));
        }
Example #2
0
        public ActionResult AccountGridActionCore(GridViewModel gridViewModel)
        {
            int?marketId = 0;

            if (Session["MarketId"] != null)
            {
                marketId = (int?)Session["MarketId"];
            }
            gridViewModel.ProcessCustomBinding(
                new GridViewCustomBindingGetDataRowCountHandler(args =>
            {
                AccountCustomBinding.AccountGetDataRowCount(args, CurrentTenantId, marketId);
            }),

                new GridViewCustomBindingGetDataHandler(args =>
            {
                AccountCustomBinding.AccountGetData(args, CurrentTenantId, marketId);
            })
                );
            return(PartialView("_AccountList", gridViewModel));
        }