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? } }
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; }