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?
            }
        }
        public void Given()
        {
            SaveAndCommit(new Tag {Name = "programming"}, new Tag {Name = ".NET"});

            _file = new MarkdownFile("name", Encoding.UTF8.GetBytes(DataMother.MarkdownFullHeader()));
            _storeToDb = new StoreMarkdownFileToDb(() => Session);
            _storeToDb.Store(new [] { _file });
        }
Esempio n. 3
0
        protected override void AdditionalSetup()
        {
            _randomFile1 = Path.GetRandomFileName() + ".md";
            var client = GetAuthorizedClient();
            client.UploadFile("/", _randomFile1, GetFileContent());

            _f = GetDropboxFacade();
            var files = _f.GetAllUnpublished();
            _file = files[0];
            _f.UpdatePublishState(files);

            var c = GetAuthorizedClient();
            _meta = c.GetMetaData();
        }
Esempio n. 4
0
 private static List<Tag> ChosenTags(MarkdownFile file, ISession s)
 {
     return (from t in s.Query<Tag>()
             where file.Tags.Contains(t.Name.ToLower())
             select t).ToList();
 }
Esempio n. 5
0
 public void Given()
 {
     _file = new MarkdownFile("name", Encoding.UTF8.GetBytes(DataMother.MarkdownFullHeader()));
 }