• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Content.ContentController类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中DotNetNuke.Entities.Content.ContentController的典型用法代码示例。如果您正苦于以下问题:C# ContentController类的具体用法?C# ContentController怎么用?C# ContentController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentController类属于DotNetNuke.Entities.Content命名空间,在下文中一共展示了ContentController类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BindData

        private void BindData()
        {
            using (var dt = new DataTable())
            {
                dt.Columns.Add(new DataColumn("TabId", typeof (Int32)));
                dt.Columns.Add(new DataColumn("ContentKey", typeof (String)));
                dt.Columns.Add(new DataColumn("Title", typeof (String)));
                dt.Columns.Add(new DataColumn("Description", typeof (String)));
                dt.Columns.Add(new DataColumn("PubDate", typeof (DateTime)));

                var results = new ContentController().GetContentItemsByTerm(_tagQuery).ToList();
                var tabController = new TabController();

                if (_tagQuery.Length > 0)
                {
                    foreach (var item in results)
                    {
                        var dr = dt.NewRow();
                        dr["TabId"] = item.TabID;
                        dr["ContentKey"] = item.ContentKey;
                        dr["Title"] = item.Content;

                        //get tab info and use the tab description, if tab is deleted then ignore the item.
                        var tab = tabController.GetTab(item.TabID, PortalId, false);
                        if(tab != null)
                        {
							if (tab.IsDeleted)
							{
								continue;
							}

							dr["Title"] = string.IsNullOrEmpty(tab.Title) ? tab.TabName : tab.Title;
                            dr["Description"] = tab.Description;
                        }
                        else
                        {
                            dr["Description"] = item.Content.Length > 1000 ? item.Content.Substring(0, 1000) : item.Content;
                        }

                        dr["PubDate"] = item.CreatedOnDate;
                        dt.Rows.Add(dr);
                    }
                }

                //Bind Search Results Grid
                var dv = new DataView(dt);
                dgResults.DataSource = dv;
                dgResults.DataBind();
              
                if (results.Count == 0)
                {
                    dgResults.Visible = false;
                    lblMessage.Text = string.Format(Localization.GetString("NoResults", LocalResourceFile), _tagQuery);
                }
                else
                {
                    lblMessage.Text = string.Format(Localization.GetString("Results", LocalResourceFile), _tagQuery);
                }
            }
        }
开发者ID:RichardHowells,项目名称:dnnextensions,代码行数:60,代码来源:ContentList.ascx.cs


示例2: DataServiceFactory

        private static Mock<IDataService> DataServiceFactory()
        {
            var dataService = new Mock<IDataService>();

            dataService.Setup(ds =>
             ds.SynchronizeMetaData(
                 It.IsAny<ContentItem>(),
                 It.IsAny<IEnumerable<KeyValuePair<string, string>>>(),
                 It.IsAny<IEnumerable<KeyValuePair<string, string>>>()))
             .Callback<ContentItem, IEnumerable<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>>(
                 (ci, added, deleted) =>
                 {
                     deleted.ToList().ForEach(
                         item => dataService.Object.DeleteMetaData(ci, item.Key, item.Value));

                     added.ToList().ForEach(
                         item => dataService.Object.AddMetaData(ci, item.Key, item.Value));
                 });

            // Register controller types that are dependent on our IDataService.
            var contentController = new ContentController(dataService.Object);

            ComponentFactory.RegisterComponentInstance<IAttachmentController>(new FileController(contentController));
            ComponentFactory.RegisterComponentInstance<IContentController>(contentController);
            ComponentFactory.RegisterComponentInstance<IFileManager>(MockHelper.CreateMockFileManager().Object);

            return dataService;
        }
开发者ID:VegasoftTI,项目名称:Dnn.Platform,代码行数:28,代码来源:AttachmentControllerTests.cs


示例3: ContentController_AddContentItem_Throws_On_Null_ContentItem

        public void ContentController_AddContentItem_Throws_On_Null_ContentItem()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentNullException>(() => controller.AddContentItem(null));
        }
开发者ID:biganth,项目名称:Curt,代码行数:9,代码来源:ContentControllerTests.cs


示例4: ContentController_AddContentItem_Calls_DataService_On_Valid_Arguments

        public void ContentController_AddContentItem_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_ValidContentItemId;

            //Act
            int contentId = controller.AddContentItem(content);

            //Assert
            mockDataService.Verify(ds => ds.AddContentItem(content, It.IsAny<int>()));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:15,代码来源:ContentControllerTests.cs


示例5: ContentController_AddContentItem_Returns_ValidId_On_Valid_ContentItem

        public void ContentController_AddContentItem_Returns_ValidId_On_Valid_ContentItem()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.AddContentItem(It.IsAny<ContentItem>(), It.IsAny<int>()))
                .Returns(Constants.CONTENT_AddContentItemId);
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_ValidContentItemId;

            //Act
            int contentId = controller.AddContentItem(content);

            //Assert
            Assert.AreEqual(Constants.CONTENT_AddContentItemId, contentId);
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:17,代码来源:ContentControllerTests.cs


示例6: ContentController_GetContentItem_Returns_ContentItem_On_Valid_ContentItemId

        public void ContentController_GetContentItem_Returns_ContentItem_On_Valid_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_ValidContentItemId))
                .Returns(MockHelper.CreateValidContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            //Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_ValidContentItemId);

            //Assert
            Assert.AreEqual(Constants.CONTENT_ValidContentItemId, content.ContentItemId);
            Assert.AreEqual(ContentTestHelper.GetContent(Constants.CONTENT_ValidContentItemId), content.Content);
            Assert.AreEqual(ContentTestHelper.GetContentKey(Constants.CONTENT_ValidContentItemId), content.ContentKey);
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:16,代码来源:ContentControllerTests.cs


示例7: ContentController_GetContentItem_Returns_Null_On_InValid_ContentItemId

        public void ContentController_GetContentItem_Returns_Null_On_InValid_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetContentItem(Constants.CONTENT_InValidContentItemId))
                .Returns(MockHelper.CreateEmptyContentItemReader());
            ContentController controller = new ContentController(mockDataService.Object);

            //Act
            ContentItem content = controller.GetContentItem(Constants.CONTENT_InValidContentItemId);

            //Assert
            Assert.IsNull(content);
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:14,代码来源:ContentControllerTests.cs


示例8: ContentController_UpdateContentItem_Calls_DataService_On_Valid_ContentItem

        public void ContentController_UpdateContentItem_Calls_DataService_On_Valid_ContentItem()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ComponentFactory.RegisterComponentInstance<IContentController>(controller);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_UpdateContentItemId;
            content.Content = Constants.CONTENT_UpdateContent;
            content.ContentKey = Constants.CONTENT_UpdateContentKey;

            //Act
            controller.UpdateContentItem(content);

            //Assert
            mockDataService.Verify(ds => ds.UpdateContentItem(content, It.IsAny<int>()));
        }
开发者ID:biganth,项目名称:Curt,代码行数:19,代码来源:ContentControllerTests.cs


示例9: ContentController_DeleteMetaData_Throws_On_Null_MetaDataName

        public void ContentController_DeleteMetaData_Throws_On_Null_MetaDataName()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();

            //Act, Arrange
            Assert.Throws<ArgumentOutOfRangeException>(() => controller.AddMetaData(content, Null.NullString, Constants.CONTENT_ValidMetaDataValue));
        }
开发者ID:biganth,项目名称:Curt,代码行数:11,代码来源:ContentControllerTests.cs


示例10: ContentController_GetUnIndexedContentItems_Returns_EmptyList_If_No_UnIndexed_Items

        public void ContentController_GetUnIndexedContentItems_Returns_EmptyList_If_No_UnIndexed_Items()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetUnIndexedContentItems())
                .Returns(MockHelper.CreateEmptyContentItemReader());

            ContentController controller = new ContentController(mockDataService.Object);

            //Act
            IQueryable<ContentItem> contentItems = controller.GetUnIndexedContentItems();

            //Assert
            Assert.AreEqual(0, contentItems.Count());
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:15,代码来源:ContentControllerTests.cs


示例11: ContentController_UpdateContentItem_Throws_On_Negative_ContentItemId

        public void ContentController_UpdateContentItem_Throws_On_Negative_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = new ContentItem();
            content.ContentItemId = Null.NullInteger;

            Assert.Throws<ArgumentException>(() => controller.UpdateContentItem(content));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:11,代码来源:ContentControllerTests.cs


示例12: ContentController_DeleteMetaData_Throws_On_Negative_ContentItemId

        public void ContentController_DeleteMetaData_Throws_On_Negative_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Null.NullInteger;

            //Act, Arrange
            Assert.Throws<ArgumentException>(() => controller.DeleteMetaData(content,
                                                                             Constants.CONTENT_ValidMetaDataName,
                                                                             Constants.CONTENT_ValidMetaDataValue));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:14,代码来源:ContentControllerTests.cs


示例13: ContentController_GetMetaData_Throws_On_Negative_ContentItemId

        public void ContentController_GetMetaData_Throws_On_Negative_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            //Act, Arrange
            Assert.Throws<ArgumentException>(() => controller.GetMetaData(Null.NullInteger));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:9,代码来源:ContentControllerTests.cs


示例14: ContentController_DeleteContentItem_Throws_On_Null_ContentItem

 public void ContentController_DeleteContentItem_Throws_On_Null_ContentItem()
 {
     //Arrange
     Mock<IDataService> mockDataService = new Mock<IDataService>();
     ContentController controller = new ContentController(mockDataService.Object);
     //Act, Arrange
     controller.DeleteContentItem(null);
 }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:8,代码来源:ContentControllerTests.cs


示例15: ContentController_DeleteMetaData_Calls_DataService_On_Valid_Arguments

        public void ContentController_DeleteMetaData_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_ValidContentItemId;

            //Act
            controller.DeleteMetaData(content, Constants.CONTENT_ValidMetaDataName, Constants.CONTENT_ValidMetaDataValue);

            //Assert
            mockDataService.Verify(
                ds =>
                ds.DeleteMetaData(content, Constants.CONTENT_ValidMetaDataName, Constants.CONTENT_ValidMetaDataValue));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:17,代码来源:ContentControllerTests.cs


示例16: ContentController_DeleteContentItem_Calls_DataService_On_Valid_ContentItemId

        public void ContentController_DeleteContentItem_Calls_DataService_On_Valid_ContentItemId()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            ContentItem content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_DeleteContentItemId;

            //Act
            controller.DeleteContentItem(content);

            //Assert
            mockDataService.Verify(ds => ds.DeleteContentItem(content));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:15,代码来源:ContentControllerTests.cs


示例17: BindData

        private void BindData()
        {
            using (var dt = new DataTable())
            {
                dt.Columns.Add(new DataColumn("TabId", typeof (Int32)));
                dt.Columns.Add(new DataColumn("ContentKey", typeof (String)));
                dt.Columns.Add(new DataColumn("Title", typeof (String)));
                dt.Columns.Add(new DataColumn("Description", typeof (String)));
                dt.Columns.Add(new DataColumn("PubDate", typeof (DateTime)));

                var results = new ContentController().GetContentItemsByTerm(_tagQuery).ToList();

                if (_tagQuery.Length > 0)
                {
                    foreach (var item in results)
                    {
                        var dr = dt.NewRow();
                        dr["TabId"] = item.TabID;
                        dr["ContentKey"] = item.ContentKey;
                        dr["Title"] = item.Content;
                        if (item.Content.Length > 1000)
                        {
                            dr["Description"] = item.Content.Substring(0, 1000);
                        }
                        else
                        {
                            dr["Description"] = item.Content;
                        }
                        dr["PubDate"] = item.CreatedOnDate;
                        dt.Rows.Add(dr);
                    }
                }

                //Bind Search Results Grid
                var dv = new DataView(dt);
                dgResults.PageSize = PageSize;
                dgResults.DataSource = dv;
                dgResults.DataBind();
                if (results.Count == 0)
                {
                    dgResults.Visible = false;
                    lblMessage.Text = string.Format(Localization.GetString("NoResults", LocalResourceFile), _tagQuery);
                }
                else
                {
                    lblMessage.Text = string.Format(Localization.GetString("Results", LocalResourceFile), _tagQuery);
                }
                if (results.Count <= dgResults.PageSize)
                {
                    ctlPagingControl.Visible = false;
                }
                else
                {
                    ctlPagingControl.Visible = true;
                }
                ctlPagingControl.TotalRecords = results.Count;
            }
            ctlPagingControl.PageSize = dgResults.PageSize;
            ctlPagingControl.CurrentPage = CurrentPage;
        }
开发者ID:sunsiz,项目名称:dnn6-chinese-language-pack,代码行数:60,代码来源:ContentList.ascx.cs


示例18: ContentController_Title_Is_Saved_On_Update

        public void ContentController_Title_Is_Saved_On_Update()
        {
            var mockDataService = new Mock<IDataService>();

            mockDataService.Setup(ds => ds.AddContentItem(It.IsAny<ContentItem>(), It.IsAny<int>()))
                .Returns(Constants.CONTENT_AddContentItemId);

            mockDataService.Setup(ds =>
             ds.SynchronizeMetaData(
                 It.IsAny<ContentItem>(),
                 It.IsAny<IEnumerable<KeyValuePair<string, string>>>(),
                 It.IsAny<IEnumerable<KeyValuePair<string, string>>>()))
             .Callback<ContentItem, IEnumerable<KeyValuePair<string, string>>, IEnumerable<KeyValuePair<string, string>>>(
                 (ci, added, deleted) =>
                 {
                     deleted.ToList().ForEach(
                         item => mockDataService.Object.DeleteMetaData(ci, item.Key, item.Value));

                     added.ToList().ForEach(
                         item => mockDataService.Object.AddMetaData(ci, item.Key, item.Value));
                 });

            // Return empty set of metadata.
            mockDataService.Setup(ds => ds.GetMetaData(It.IsAny<int>())).Returns(MockHelper.CreateValidMetaDataReader);

            var controller = new ContentController(mockDataService.Object);

            // The ContentExtensions methods look this up.
            ComponentFactory.RegisterComponentInstance<IContentController>(controller);

            var content = ContentTestHelper.CreateValidContentItem();
            content.ContentItemId = Constants.CONTENT_ValidContentItemId;
            content.ContentTitle = Constants.CONTENT_ValidTitle;

            //Act
            controller.AddContentItem(content);

            content.ContentTitle = Constants.CONTENT_ValidTitle2;
            controller.UpdateContentItem(content);

            //Assert
            mockDataService.Verify(ds => ds.AddMetaData(content, AttachmentController.TitleKey, Constants.CONTENT_ValidTitle));
            mockDataService.Verify(ds => ds.AddMetaData(content, AttachmentController.TitleKey, Constants.CONTENT_ValidTitle2));
        }
开发者ID:biganth,项目名称:Curt,代码行数:44,代码来源:ContentControllerTests.cs


示例19: ContentController_GetMetaData_Calls_DataService_On_Valid_Arguments

        public void ContentController_GetMetaData_Calls_DataService_On_Valid_Arguments()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            mockDataService.Setup(ds => ds.GetMetaData(Constants.CONTENT_ValidContentItemId))
                .Returns(MockHelper.CreateValidMetaDataReader());
            ContentController controller = new ContentController(mockDataService.Object);

            //Act
            NameValueCollection metaData = controller.GetMetaData(Constants.CONTENT_ValidContentItemId);

            //Assert
            mockDataService.Verify(ds => ds.GetMetaData(Constants.CONTENT_ValidContentItemId));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:14,代码来源:ContentControllerTests.cs


示例20: ContentController_DeleteMetaData_Throws_On_Null_MetaDataName

        public void ContentController_DeleteMetaData_Throws_On_Null_MetaDataName()
        {
            //Arrange
            Mock<IDataService> mockDataService = new Mock<IDataService>();
            ContentController controller = new ContentController(mockDataService.Object);

            //Act, Arrange
            AutoTester.ArgumentNull<ContentItem>(content => controller.DeleteMetaData(content,
                                                                                      Null.NullString,
                                                                                      Constants.
                                                                                          CONTENT_ValidMetaDataValue));
        }
开发者ID:neogic,项目名称:DotNetNuke_SVN,代码行数:12,代码来源:ContentControllerTests.cs



注:本文中的DotNetNuke.Entities.Content.ContentController类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Taxonomy.TermController类代码示例发布时间:2022-05-24
下一篇:
C# Utilities.CacheItemArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap