当前位置: 首页>>代码示例>>C#>>正文


C# PageViewModel.CommaDelimitedTags方法代码示例

本文整理汇总了C#中Roadkill.Core.Mvc.ViewModels.PageViewModel.CommaDelimitedTags方法的典型用法代码示例。如果您正苦于以下问题:C# PageViewModel.CommaDelimitedTags方法的具体用法?C# PageViewModel.CommaDelimitedTags怎么用?C# PageViewModel.CommaDelimitedTags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Roadkill.Core.Mvc.ViewModels.PageViewModel的用法示例。


在下文中一共展示了PageViewModel.CommaDelimitedTags方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CommaDelimitedTags_Should_Return_Tags_In_Csv_Form

        public void CommaDelimitedTags_Should_Return_Tags_In_Csv_Form()
        {
            // Arrange
            PageViewModel model = new PageViewModel();
            model.RawTags = "tag1, tag2, tag3";

            // Act
            string joinedTags = model.CommaDelimitedTags();

            // Assert
            Assert.That(joinedTags, Is.EqualTo("tag1,tag2,tag3"));
        }
开发者ID:NaseUkolyCZ,项目名称:roadkill,代码行数:12,代码来源:PageViewModelTests.cs

示例2: AddPage

        /// <summary>
        /// Adds the page to the database.
        /// </summary>
        /// <param name="model">The summary details for the page.</param>
        /// <returns>A <see cref="PageViewModel"/> for the newly added page.</returns>
        /// <exception cref="DatabaseException">An databaseerror occurred while saving.</exception>
        /// <exception cref="SearchException">An error occurred adding the page to the search index.</exception>
        public PageViewModel AddPage(PageViewModel model)
        {
            try
            {
                string currentUser = _context.CurrentUsername;

                Page page = new Page();
                page.Title = model.Title;
                page.Tags = model.CommaDelimitedTags();
                page.CreatedBy = AppendIpForDemoSite(currentUser);
                page.CreatedOn = DateTime.UtcNow;
                page.ModifiedOn = DateTime.UtcNow;
                page.ModifiedBy = AppendIpForDemoSite(currentUser);
                page.ProjectStart = model.ProjectStart;
                page.ProjectEnd = model.ProjectEnd;
                page.ProjectEstimatedTime = model.ProjectEstimatedTime;
                page.ProjectLanguage = model.ProjectLanguage;
                page.ProjectStatus = model.ProjectStatus;
                page.orgID = model.orgID;

                // Double check, incase the HTML form was faked.
                if (_context.IsAdmin)
                    page.IsLocked = model.IsLocked;

                PageContent pageContent = Repository.AddNewPage(page, model.Content, AppendIpForDemoSite(currentUser), DateTime.UtcNow, model.ProjectStart, model.ProjectEnd, model.ProjectEstimatedTime, model.ProjectStatus, model.ProjectLanguage, model.orgID);

                _listCache.RemoveAll();
                _pageViewModelCache.RemoveAll(); // completely clear the cache to update any reciprocal links.

                // Update the lucene index
                PageViewModel savedModel = new PageViewModel(pageContent, _markupConverter);
                try
                {
                    _searchService.Add(savedModel);
                }
                catch (SearchException)
                {
                    // TODO: log
                }

                return savedModel;
            }
            catch (DatabaseException e)
            {
                throw new DatabaseException(e, "An error occurred while adding page '{0}' to the database", model.Title);
            }
        }
开发者ID:LocalGovDigital,项目名称:pipeline,代码行数:54,代码来源:PageService.cs

示例3: UpdatePage

        /// <summary>
        /// Updates the provided page.
        /// </summary>
        /// <param name="model">The summary.</param>
        /// <exception cref="DatabaseException">An databaseerror occurred while updating.</exception>
        /// <exception cref="SearchException">An error occurred adding the page to the search index.</exception>
        public void UpdatePage(PageViewModel model)
        {
            try
            {
                string currentUser = _context.CurrentUsername;

                Page page = Repository.GetPageById(model.Id);
                page.Title = model.Title;
                page.Tags = model.CommaDelimitedTags();
                page.ModifiedOn = DateTime.UtcNow;
                page.ModifiedBy = AppendIpForDemoSite(currentUser);
                page.ProjectStart = model.ProjectStart;
                page.ProjectEnd = model.ProjectEnd;
                page.ProjectEstimatedTime = model.ProjectEstimatedTime;
                page.ProjectLanguage = model.ProjectLanguage;
                page.ProjectStatus = model.ProjectStatus;
                page.orgID = model.orgID;

                // A second check to ensure a fake IsLocked POST doesn't work.
                if (_context.IsAdmin)
                    page.IsLocked = model.IsLocked;

                Repository.SaveOrUpdatePage(page);

                //
                // Update the cache - updating a page is expensive for the cache right now
                // this could be improved by updating the item in the listcache instead of invalidating it
                //
                _pageViewModelCache.Remove(model.Id, 0);

                if (model.Tags.Contains("homepage"))
                    _pageViewModelCache.RemoveHomePage();

                _listCache.RemoveAll();

                int newVersion = _historyService.MaxVersion(model.Id) + 1;
                PageContent pageContent = Repository.AddNewPageContentVersion(page, model.Content, AppendIpForDemoSite(currentUser), DateTime.UtcNow, newVersion, model.ProjectStart, model.ProjectEnd, model.ProjectEstimatedTime, model.ProjectStatus, model.ProjectLanguage, model.orgID);

                // Update all links to this page (if it has had its title renamed). Case changes don't need any updates.
                if (model.PreviousTitle != null && model.PreviousTitle.ToLower() != model.Title.ToLower())
                {
                    UpdateLinksToPage(model.PreviousTitle, model.Title);
                }

                // Update the lucene index
                PageViewModel updatedModel = new PageViewModel(Repository.GetLatestPageContent(page.Id), _markupConverter);
                _searchService.Update(updatedModel);
            }
            catch (DatabaseException ex)
            {
                throw new DatabaseException(ex, "An error occurred updating the page with title '{0}' in the database", model.Title);
            }
        }
开发者ID:LocalGovDigital,项目名称:pipeline,代码行数:59,代码来源:PageService.cs

示例4: commadelimitedtags_should_return_tags_in_csv_form

		public void commadelimitedtags_should_return_tags_in_csv_form()
		{
			// Arrange
			PageViewModel model = new PageViewModel();
			model.RawTags = "tag1, tag2, tag3";

			// Act
			string joinedTags = model.CommaDelimitedTags();

			// Assert
			Assert.That(joinedTags, Is.EqualTo("tag1,tag2,tag3"));
		}
开发者ID:RyanGroom,项目名称:roadkill,代码行数:12,代码来源:PageViewModelTests.cs


注:本文中的Roadkill.Core.Mvc.ViewModels.PageViewModel.CommaDelimitedTags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。