Inheritance: Entity
Esempio n. 1
0
        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?
            }
        }
Esempio n. 2
0
 private void MapData(Content content)
 {
     MainData(content);
     SetTimeInfo(content);
     HandleAttachments(content);
     
     Tags = content.Tags != null ? content.Tags.Select(t => t.Name) : new string[] { };
 }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        private void HandleAttachments(Content content)
        {
            AttachmentCount = content.AttachmentCount;

            if (AttachmentCount > 0)
            {
                var converter = new AttachmentConverter(_siteSettings);
                Attachments = content.Attachments.Select(converter.Convert);
            }
        }
Esempio n. 7
0
 public void ContainsWillSaythatItemDoesNotExist()
 {
     var c = new Content(13);
     var repC = new Repository<Content>(Factory);
     Assert.IsFalse(repC.Contains(c));
 }