本文整理汇总了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;未经允许,请勿转载。 |
请发表评论