本文整理汇总了C#中DotNetNuke.Entities.Content.ContentController类的典型用法代码示例。如果您正苦于以下问题:C# ContentController类的具体用法?C# ContentController怎么用?C# ContentController使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ContentController类属于DotNetNuke.Entities.Content命名空间,在下文中一共展示了ContentController类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
}
示例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;
}
示例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));
}
示例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>()));
}
示例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);
}
示例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);
}
示例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);
}
示例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>()));
}
示例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));
}
示例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());
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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));
}