コード例 #1
0
ファイル: NewsList.aspx.cs プロジェクト: sang-nm/mphc
        public bool DeleteContent(string newsId)
        {
            try
            {
                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                News         news         = new News(siteSettings.SiteId, Convert.ToInt32(newsId));

                if (news != null && news.NewsID != -1)
                {
                    NewsHelper.DeleteFolder(siteSettings.SiteId, news.NewsID);

                    ContentMedia.DeleteByContent(news.NewsGuid);

                    var listAtributes = ContentAttribute.GetByContentAsc(news.NewsGuid);
                    foreach (ContentAttribute item in listAtributes)
                    {
                        ContentLanguage.DeleteByContent(item.Guid);
                    }
                    ContentAttribute.DeleteByContent(news.NewsGuid);
                    ContentLanguage.DeleteByContent(news.NewsGuid);

                    news.Delete();
                    FriendlyUrl.DeleteByPageGuid(news.NewsGuid);

                    FileAttachment.DeleteByItem(news.NewsGuid);
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }
コード例 #2
0
        public bool DeleteContent(string productId)
        {
            try
            {
                SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings();
                Product      product      = new Product(siteSettings.SiteId, Convert.ToInt32(productId));

                if (product != null && product.ProductId != -1)
                {
                    ProductHelper.DeleteFolder(siteSettings.SiteId, product.ProductId);

                    ContentMedia.DeleteByContent(product.ProductGuid);
                    ShoppingCartItem.DeleteByProduct(product.ProductId);

                    var listAtributes = ContentAttribute.GetByContentAsc(product.ProductGuid);
                    foreach (ContentAttribute item in listAtributes)
                    {
                        ContentLanguage.DeleteByContent(item.Guid);
                    }
                    ContentAttribute.DeleteByContent(product.ProductGuid);
                    ContentLanguage.DeleteByContent(product.ProductGuid);

                    ProductProperty.DeleteByProduct(product.ProductId);
                    FriendlyUrl.DeleteByPageGuid(product.ProductGuid);

                    ProductComment.DeleteByProduct(product.ProductId);
                    TagItem.DeleteByItem(product.ProductGuid);

                    FileAttachment.DeleteByItem(product.ProductGuid);
                    RelatedItem.DeleteByItem(product.ProductGuid);

                    product.Delete();
                }
            }
            catch (Exception) { return(false); }

            return(true);
        }