private void Store(MarkdownFile file) { try { var s = _session.Value; using (var tx = s.BeginTransaction()) { var chosenTags = ChosenTags(file, s); var c = new Content { IsMarkdown = true, Published = true, Created = file.Publish.HasValue ? file.Publish.Value : DateTime.UtcNow, Title = file.Title }; c.SetBody(file.PostBody); chosenTags.ForEach(c.AssociateWithTag); s.Save(c); tx.Commit(); file.HasBeenStoredLocally = true; } } catch (Exception) { // What could we sensibly do? } }
private void MapData(Content content) { MainData(content); SetTimeInfo(content); HandleAttachments(content); Tags = content.Tags != null ? content.Tags.Select(t => t.Name) : new string[] { }; }
private void MainData(Content content) { ContentId = content.Id.ToString(); Title = content.Title; Body = content.IsMarkdown.HasValue && (bool)content.IsMarkdown ? new MarkdownTransformer(content.Body) : content.Body; new CodeHighlightExtension().Inspect(this); Keywords = content.MetaKeyWords; }
public Content CreateContent(int id, string title, DateTime created) { var content = new Content(id) { Title = title, Published = true, Created = created }; content.SetBody("Body"); return content; }
public ContentVM( Content content, SiteSettings siteSettings, ServerVariables vars, IUrlRegistry registry) { _siteSettings = siteSettings; if (content == null) return; var url = registry != null && vars != null ? registry.BuildAbsoluteUrlTemplate(vars, r => r.UrlFor(new ContentId(content.Id))) : null; CommentData = new CommentDataVM( content.Id, url, _siteSettings.DisqusSiteIdentifier, _siteSettings.DisqusDeveloperMode, HtmlTags.JsonUtil.ToJson(content.Title)); MapData(content); }
private void HandleAttachments(Content content) { AttachmentCount = content.AttachmentCount; if (AttachmentCount > 0) { var converter = new AttachmentConverter(_siteSettings); Attachments = content.Attachments.Select(converter.Convert); } }
public void ContainsWillSaythatItemDoesNotExist() { var c = new Content(13); var repC = new Repository<Content>(Factory); Assert.IsFalse(repC.Contains(c)); }