public override void PopulateAllUIElements(Framework.EntityContracts.IViewModelBase <TSearchCriteria> vmFromTempData, int currentPage)
 {
     base.PopulateAllUIElements(vmFromTempData, currentPage);
     this.SelectListOfQueryOrderBySettingCollecionInString = Framework.Mvc.MvcHelper.BuildListOfSelectListItem(this.ListOfQueryOrderBySettingCollecionInString);
     this.SelectListOfPageSize   = Framework.Mvc.MvcHelper.BuildListOfSelectListItem(this.QueryPagingSetting.PageSizeSelectionList);
     this.SelectListOfDataExport = Framework.Mvc.MvcHelper.BuildListOfSelectListItem(this.ListOfDataExport);
 }
Exemplo n.º 2
0
        public virtual void PopulateAllUIElements(Framework.EntityContracts.IViewModelBase <TSearchCriteria> vmFromTempData, int currentPage)
        {
            // 1. Criteria
            if (this.Criteria == null)
            {
                if (vmFromTempData != null && vmFromTempData.Criteria != null)
                {
                    this.Criteria = vmFromTempData.Criteria;
                }
                else
                {
                    this.Criteria = new TSearchCriteria();
                }
            }

            // 2. ListOfQueryOrderBySettingCollecionInString
            if (this.ListOfQueryOrderBySettingCollecionInString == null)
            {
                if (vmFromTempData != null && vmFromTempData.ListOfQueryOrderBySettingCollecionInString != null)
                {
                    this.ListOfQueryOrderBySettingCollecionInString = vmFromTempData.ListOfQueryOrderBySettingCollecionInString;
                }
                else
                {
                    this.ListOfQueryOrderBySettingCollecionInString = GetDefaultListOfQueryOrderBySettingCollecionInString();
                }
            }

            // 3. QueryPagingSetting

            if (this.QueryPagingSetting == null)
            {
                if (vmFromTempData != null && vmFromTempData.QueryPagingSetting != null)
                // first time, pagination
                {
                    this.QueryPagingSetting             = vmFromTempData.QueryPagingSetting;
                    this.QueryPagingSetting.CurrentPage = currentPage;
                }
                else
                {
                    this.QueryPagingSetting = GetDefaultQueryPagingSetting();
                }
            }
            else
            {
                if (this.QueryPagingSetting.PageSizeChanged)
                {
                    this.QueryPagingSetting.CurrentPage      = 1;
                    this.QueryPagingSetting.OriginalPageSize = this.QueryPagingSetting.PageSize;
                }
                else if (this.OriginalQueryOrderBySettingCollecionInString != this.QueryOrderBySettingCollecionInString)
                {
                    this.OriginalQueryOrderBySettingCollecionInString = this.QueryOrderBySettingCollecionInString;
                    this.QueryPagingSetting.CurrentPage = 1;
                }
                else
                {
                    this.QueryPagingSetting.CurrentPage = 1;
                }
            }

            // 4. QueryOrderBySettingCollecionInString
            if (string.IsNullOrWhiteSpace(this.QueryOrderBySettingCollecionInString))
            {
                if (vmFromTempData != null && !string.IsNullOrWhiteSpace(vmFromTempData.QueryOrderBySettingCollecionInString))
                // first time, pagination
                {
                    this.QueryOrderBySettingCollecionInString = vmFromTempData.QueryOrderBySettingCollecionInString;
                }
            }

            // 4.1. QueryOrderBySettingCollecion
            if (!string.IsNullOrWhiteSpace(this.QueryOrderBySettingCollecionInString))
            {
                this.QueryOrderBySettingCollection = new Framework.EntityContracts.QueryOrderBySettingCollection(this.QueryOrderBySettingCollecionInString);
            }

            // 5. GetDefaultPerViewModel
            this.GetDefaultPerViewModel();

            if (this.ListOfDataExport == null)
            {
                if (vmFromTempData != null && vmFromTempData.ListOfDataExport != null)
                // first time, pagination
                {
                    this.ListOfDataExport = vmFromTempData.ListOfDataExport;
                }
                else
                {
                    this.ListOfDataExport = new Framework.NameValueCollection();
                    this.ListOfDataExport.Add("Csv", "Csv");
                    this.ListOfDataExport.Add("Excel2010", "Excel2010");
                }
            }
        }