public void Should_Return_Collection() { var dataContext = new Mock<IAtomicCmsDataRepository>(); var logger = new Mock<LoggingService>(); ICollection<PageTag> pagesTagsCollection = new List<PageTag>(); CmsPage page1 = new CmsPage(){Id = 1}; CmsPage page2 = new CmsPage(){Id = 2}; CmsPage page3 = new CmsPage(){Id = 3}; CmsTag tag1 = new CmsTag() { Id = 1 }; CmsTag tag2 = new CmsTag() { Id = 2 }; CmsTag tag3 = new CmsTag() { Id = 3 }; pagesTagsCollection.Add(new PageTag(){Page = page1, Tag = tag1}); pagesTagsCollection.Add(new PageTag() { Page = page1, Tag = tag2 }); pagesTagsCollection.Add(new PageTag() { Page = page2, Tag = tag1 }); pagesTagsCollection.Add(new PageTag() { Page = page2, Tag = tag3 }); pagesTagsCollection.Add(new PageTag() { Page = page3, Tag = tag1 }); pagesTagsCollection.Add(new PageTag() { Page = page3, Tag = tag2 }); dataContext.Setup(x => x.GetPagesTags()).Returns(pagesTagsCollection); WidgetService widgetService = new WidgetService(dataContext.Object, logger.Object); var c = new WidgetsController(widgetService); ActionResult ar = c.TagCloud(); var view = ar as PartialViewResult; Assert.IsNotNull(view); Assert.IsNotEmpty((ICollection) view.ViewData.Model); ICollection<TagCount> tagCounts = view.ViewData.Model as ICollection<TagCount>; Assert.IsNotNull(tagCounts); Assert.AreEqual(3, tagCounts.Count); Assert.AreEqual(3, new List<TagCount>(tagCounts)[0].Count); Assert.AreEqual(2, new List<TagCount>(tagCounts)[1].Count); Assert.AreEqual(1, new List<TagCount>(tagCounts)[2].Count); }
private void UpdatePageStatus(CmsPage page, IValueProvider valueProvider) { int pageStatusId; if (Int32.TryParse(valueProvider.GetValue("Page.Status.Id").AttemptedValue, out pageStatusId)) { Status pageStatus = pageService.LoadPageType(pageStatusId); page.Status = pageStatus; } }
private void AddHomePage(Sitemap sitemap, CmsPage page, string homePage) { var url = new SitemapUrl(); url.Location = homePage; url.ChangeFrequency = CalculateFrequency(page.ModifiedAt); url.Priority = 0.9; url.LastModified = page.ModifiedAt.ToString(); sitemap.Insert(0, url); }
public void Should_Permanent_redirect_if_wrong_alias_provided_for_page_id() { int pageId = 3; var expectedPage = new CmsPage {Id = pageId, Alias = "expected-alias"}; pageData.Setup(x => x.Load(pageId)).Returns(expectedPage); var result = c.Content(pageId, "this-is-wrong_alias") as LegacyUrl301Result; Assert.IsNotNull(result); string expectedUrl = expectedPage.GetUrl(); Assert.AreEqual(expectedUrl, result.NewUrl); }
public static MvcHtmlString PageTitle(this HtmlHelper hh, CmsPage page) { if (hh.IsDefaultPage()) { return MvcHtmlString.Create(page.PageTitle); } return hh.ActionLink(page.PageTitle, "Content", "Home", new {area = "", id = page.Id, name = page.Alias}, new {title = page.PageTitle}); }
public static MvcHtmlString ActionPageLink(this HtmlHelper hh, CmsPage p) { return hh.ActionLink(p.PageTitle, "Content", "Home", new { id = p.Id, name = p.Alias, area = "" }, new {title = p.PageTitle}); }
private ActionResult ShowPage(CmsPage entry) { return View("Index", entry); }
private ActionResult ShowPage(string page, CmsPage entry) { return View(page, entry); }
public void Save(CmsPage entry, string identity) { entry.ModifiedAt = DateTime.Now; FillTags(entry); EnsureFieldsAreFilled(entry); entry.Author = userData.Find(identity); pageData.Save(entry); }
private void FillTags(CmsPage page) { if (null == page) { return; } page.Tags.Clear(); if (null != page.TagString && !string.IsNullOrEmpty(page.TagString.AttemptedValue)) { string[] tags = page.TagString.AttemptedValue.Split(new[] {','}, StringSplitOptions.RemoveEmptyEntries); foreach (string tag in tags) { string tagName = tag.Trim(); if (string.IsNullOrEmpty(tagName)) continue; CmsTag cmsTag = pageData.LoadTag(tagName); if (null != cmsTag && !page.Tags.Contains(cmsTag)) { page.Tags.Add(cmsTag); } else { IEnumerable<CmsTag> alreadyCreated = page.Tags.Where(x => x.Name == tag.Trim()); if (alreadyCreated.Count() == 0) { page.Tags.Add(new CmsTag {Name = tag.Trim()}); } } } } }
private void EnsureFieldsAreFilled(CmsPage entry) { if (string.IsNullOrEmpty(entry.SeoTitle)) { entry.SeoTitle = entry.PageTitle; } if (string.IsNullOrEmpty(entry.MetaKeywords)) { entry.MetaKeywords = entry.Tags.ToTagString(); } if (string.IsNullOrEmpty(entry.MetaDescription)) { entry.MetaDescription = entry.PageTitle; } }
public void CreateEntry(CmsPage entry, string userName) { entry.ModifiedAt = DateTime.Now; entry.CreatedAt = DateTime.Now; entry.Author = userData.Find(userName); EnsureFieldsAreFilled(entry); pageData.Save(entry); }
private bool IsDefaultPage(CmsPage page, int homePageId) { return page.Id == homePageId; }