Engage.Dnn.Publish.Category.GetOldCategoryId C# (CSharp) Method

GetOldCategoryId() public static method

public static GetOldCategoryId ( int itemId ) : int
itemId int
return int
        public static int GetOldCategoryId(int itemId)
        {
            return DataProvider.Instance().GetOldCategoryId(itemId);
        }

Usage Example

Exemplo n.º 1
0
        public int ResolveId()
        {
            //TODO: Need to test this method with a database (children's) that has all the scenarios.
            //NOTE: At this point I'm not sure of the presedence here. The other issue is that within the
            //presedence issue there may be "exit" situations which is hard to control/debug. Need valid
            //test cases to further refactor.hk

            int id = -1;

            //there is an oldArticleId and displayOption is "Article"
            //NOTE: TO make these work you must verify that the mapping tables exists.
            //Publish_CategoryMapping
            //Columns:  NewItemId and OldArticleID
            //Publish_ArticleMapping
            //Columns: NewItemId and OldCateogryID

            if (PreviousArticleId != -1 && string.Compare(DisplayOption, "texthtml", StringComparison.OrdinalIgnoreCase) == 0)
            {
                id = ItemId;
            }

            //Verify that these tables have been populated correctly! hk
            if (PreviousArticleId != -1 && string.Compare(DisplayOption, "article", StringComparison.OrdinalIgnoreCase) == 0)
            {
                id = Article.GetOldArticleId(PreviousArticleId);
            }

            //there is an oldArticleID and displayOption is either "Title" or "Abstract"
            if (PreviousCategoryId != -1 && (string.Compare(DisplayOption, "title", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(DisplayOption, "abstract", StringComparison.OrdinalIgnoreCase) == 0))
            {
                id = Category.GetOldCategoryId(PreviousCategoryId);
            }

            //Old article ID passed in (aid).
            object oAid = HttpContext.Current.Request.QueryString["aid"];

            if (oAid != null)
            {
                id = Article.GetOldArticleId(Convert.ToInt32(oAid, CultureInfo.InvariantCulture));
            }

            //There is an ArticleId
            if (AdArticleId != -1 && DisplayType == "ArticleDisplay")
            {
                if (!IsOverrideable || (IsOverrideable && id == -1))
                {
                    id = AdArticleId;
                }
            }
            else if (AdArticleId != -1 && String.IsNullOrEmpty(DisplayType))
            {
                id = AdArticleId;
            }

            //There is a CategoryId
            if (CategoryId != -1 && (DisplayType == "CategoryDisplay" || DisplayType == "ItemListing" || DisplayType == "CategoryFeatureDisplay" || DisplayType == "CategorySearch" || DisplayType == "CategoryNLevels" || DisplayType == "CustomDisplay"))
            {
                if (!IsOverrideable || (IsOverrideable && id == -1))
                {
                    id = CategoryId;
                }
            }

            if (CategoryId != -1 && String.IsNullOrEmpty(DisplayType))
            {
                id = CategoryId;
            }

            return(id);
        }