Ejemplo n.º 1
0
        public static string GetListAllItemView(long pageNo, long itemsPerPage, long dataIndex, string templateSuffix, bool asyncLoading, long filterInfoCategoryId, string filterInfoPage, bool filterInfoPagePublic, long filterCreatedUserId, bool hideFilter)
        {
            string message = "";

            if (itemsPerPage == 0)
            {
                itemsPerPage = UtilsGeneric.DefaultItemsPerPage;
            }
            long   totalPages;
            long   totalItems;
            string htmlTextItemList   = "";
            string htmlAddItemList    = "";
            string htmlFilterItemList = "";

            //if ((filterInfoCategoryId > 0) || (filterInfoPage.Trim().Length > 0) || (filterInfoPagePublic == true)) hideFilter = false;

            #region Filter Section

            List <TemplateInfoPageListDetailFilter.ShowPublicChecked>   showPublicCheckedList   = new List <TemplateInfoPageListDetailFilter.ShowPublicChecked>();
            List <TemplateInfoPageListDetailFilter.ShowPublicUnChecked> showPublicUnCheckedList = new List <TemplateInfoPageListDetailFilter.ShowPublicUnChecked>();

            if (filterInfoPagePublic == true)
            {
                showPublicCheckedList.Add(new TemplateInfoPageListDetailFilter.ShowPublicChecked
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    AsyncLoading   = asyncLoading.ToString().ToLower()
                });
            }
            else
            {
                showPublicUnCheckedList.Add(new TemplateInfoPageListDetailFilter.ShowPublicUnChecked
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    AsyncLoading   = asyncLoading.ToString().ToLower()
                });
            }

            #region Get Info Category List

            List <LTD_InfoCategory> ltdInfoCategoryList = DataInfoList.GetAllActiveLtdInfoCategory();

            bool firstRecord = true;
            List <TemplateInfoPageListDetailFilter.InfoCategoryItem> infoCategoryItemList = new List <TemplateInfoPageListDetailFilter.InfoCategoryItem>();
            if (ltdInfoCategoryList.Count == 0)
            {
                infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem
                {
                    InfoCategoryText     = "No Info Category Found",
                    InfoCategoryValue    = "1",
                    InfoCategorySelected = true
                });
            }
            else
            {
                infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem
                {
                    InfoCategoryText     = "Select Category Filter",
                    InfoCategoryValue    = "0",
                    InfoCategorySelected = (filterInfoCategoryId == 0)
                });
                if (filterInfoCategoryId == 0)
                {
                    firstRecord = false;
                }
            }

            if (filterInfoCategoryId != 0)
            {
                LTD_InfoCategory ltdInfoCategory = DataInfoList.GetLtdInfoCategory(filterInfoCategoryId);
                if (ltdInfoCategory != null)
                {
                    infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem
                    {
                        InfoCategoryText     = ltdInfoCategory.InfoCategoryName,
                        InfoCategoryValue    = ltdInfoCategory.InfoCategoryID.ToString(),
                        InfoCategorySelected = true,
                    });
                    firstRecord = false;
                }
            }

            foreach (LTD_InfoCategory ltdInfoCategory in ltdInfoCategoryList)
            {
                if (ltdInfoCategory.InfoCategoryID != filterInfoCategoryId)
                {
                    if ((filterInfoCategoryId == 0) && (firstRecord == true))
                    {
                        infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem
                        {
                            InfoCategoryText     = ltdInfoCategory.InfoCategoryName,
                            InfoCategoryValue    = ltdInfoCategory.InfoCategoryID.ToString(),
                            InfoCategorySelected = true
                        });
                    }
                    else
                    {
                        infoCategoryItemList.Add(new TemplateInfoPageListDetailFilter.InfoCategoryItem
                        {
                            InfoCategoryText     = ltdInfoCategory.InfoCategoryName,
                            InfoCategoryValue    = ltdInfoCategory.InfoCategoryID.ToString(),
                            InfoCategorySelected = false,
                        });
                    }
                }
                firstRecord = false;
            }

            #endregion

            long   selectedUserId        = 0;
            string selectUserDetailsHtml = "";
            string userSelectNameId      = "infoPageUserFilter";

            if (UtilsSecurity.HaveAdminRole() == true)
            {
                selectedUserId = UtilsSecurity.GetUserId();
                if (filterCreatedUserId > 0)
                {
                    selectedUserId = filterCreatedUserId;
                }

                #region User Select View

                long   userViewDataIndex    = dataIndex + 5;
                string showFunctionScript   = "";
                string selectChangeCallback = " filterInfoPageList(" + pageNo + "," + itemsPerPage + "," + dataIndex + ",'" + templateSuffix + "'," + asyncLoading.ToString().ToLower() + ") ";
                selectUserDetailsHtml = UserAdminView.GetUserSelectView(userViewDataIndex, 1, 25, templateSuffix, selectedUserId, false, showFunctionScript, "", userSelectNameId, selectChangeCallback, out selectedUserId);

                #endregion
            }

            TemplateInfoPageListDetailFilter listDetailFilter = new TemplateInfoPageListDetailFilter
            {
                InfoPageListFilterHidden = hideFilter,

                ShowPublicCheckedList   = showPublicCheckedList,
                ShowPublicUnCheckedList = showPublicUnCheckedList,
                InfoCategoryItemList    = infoCategoryItemList,
                InfoPageFilter          = filterInfoPage,

                DataIndex      = dataIndex.ToString(),
                PageNo         = pageNo.ToString(),
                ItemsPerPage   = itemsPerPage.ToString(),
                TemplateSuffix = templateSuffix,
                AsyncLoading   = asyncLoading.ToString().ToLower(),

                UserSelect = selectUserDetailsHtml,
            };
            htmlFilterItemList = listDetailFilter.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);

            #endregion

            #region Add Link

            List <TemplateInfoPageSaveAdd.AddAction> addActionList = new List <TemplateInfoPageSaveAdd.AddAction>();

            if (UtilsSecurity.HaveAuthorRoleEnabled() == true)
            {
                addActionList.Add(new TemplateInfoPageSaveAdd.AddAction
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                });
            }

            TemplateInfoPageSaveAdd templateSaveAdd = new TemplateInfoPageSaveAdd
            {
                AddActionList = addActionList,
            };
            htmlAddItemList = templateSaveAdd.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);

            #endregion

            #region Get Fill List

            #region Get Paged Data

            List <LTD_InfoPage> ltdInfoPageList = new List <LTD_InfoPage>();

            if (UtilsSecurity.IsAuthenticated() == true)
            {
                if (filterInfoPagePublic == true)
                {
                    ltdInfoPageList = DataInfoList.GetPublicPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems);
                }
                else
                {
                    if (UtilsSecurity.HaveAdminRole() == true)
                    {
                        ltdInfoPageList = DataInfoList.GetPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems);
                    }
                    else
                    {
                        ltdInfoPageList = DataInfoList.GetUserPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, pageNo, itemsPerPage, out totalPages, out totalItems);
                    }

                    long commonTotalPages = 0;
                    long commonTotalItems = 0;
                    List <LTD_InfoPage> commonltdInfoPageList = DataInfoList.GetCommonPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, pageNo, itemsPerPage, out commonTotalPages, out commonTotalItems);
                    if (commonltdInfoPageList.Count > 0)
                    {
                        ltdInfoPageList.AddRange(commonltdInfoPageList);
                        totalItems = totalItems + commonTotalItems;
                        if (commonTotalPages > 1)
                        {
                            totalPages = totalPages + commonTotalPages - 1;
                        }
                    }
                }
            }
            else
            {
                ltdInfoPageList = DataInfoList.GetPublicPagedLtdInfoPage(filterInfoCategoryId, filterInfoPage, selectedUserId, pageNo, itemsPerPage, out totalPages, out totalItems);
            }

            #endregion

            if (ltdInfoPageList.Count > 0)
            {
                #region Get Pager Details

                string topPagerDetails    = UtilsGeneric.GetItemPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, RefreshListFunctionName, asyncLoading.ToString().ToLower());
                string bottomPagerDetails = UtilsGeneric.GetLinkPagerView(pageNo, itemsPerPage, dataIndex, templateSuffix, totalPages, totalItems, RefreshListFunctionName, asyncLoading.ToString().ToLower(), false);

                #endregion

                #region Append Top Pager

                if (topPagerDetails.Trim().Length > 0)
                {
                    htmlTextItemList += topPagerDetails;
                }

                #endregion

                #region Append Items

                int index = 0;
                for (; index < ltdInfoPageList.Count; index++)
                {
                    LTD_InfoPage ltdInfoPage          = ltdInfoPageList[index];
                    string       htmlTextItemTemplate = GetListSingleItemView(ltdInfoPage, pageNo, itemsPerPage, dataIndex, templateSuffix, index, asyncLoading);
                    htmlTextItemList += htmlTextItemTemplate;
                }

                #endregion

                #region Append Bottom Pager

                if (bottomPagerDetails.Trim().Length > 0)
                {
                    htmlTextItemList += bottomPagerDetails;
                }

                #endregion
            }

            #endregion

            #region Set Fill List

            if (htmlTextItemList.Length == 0)
            {
                TemplateInfoPageListDetailEmpty templateListDetailEmpty = new TemplateInfoPageListDetailEmpty
                {
                    DataIndex      = dataIndex.ToString(),
                    PageNo         = pageNo.ToString(),
                    ItemsPerPage   = itemsPerPage.ToString(),
                    TemplateSuffix = templateSuffix,
                    AsyncLoading   = asyncLoading.ToString().ToLower()
                };
                htmlTextItemList = templateListDetailEmpty.GetFilled(templateSuffix, UtilsGeneric.Validate, UtilsGeneric.ThrowException, out message);
            }
            #endregion

            return(htmlFilterItemList + htmlAddItemList + htmlTextItemList);
        }