Exemple #1
0
        public bool Add(Entry entry)
        {
            entry.CreatedAt = DateTime.Now;
            entry.PublishedAt = DateTime.Now;
            entry.Summary = "coming soon.";

            try
            {
                var context = new BlogDatabase();
                using (var tagRepo = new Repository<Tag>(context))
                using (var entryRepo = new Repository<Entry>(context))
                {
                    foreach (var tag in entry.Tags)
                        tagRepo.Attach(tag);

                    entryRepo.Add(entry);
                    return true;
                }
            }
            catch (Exception)
            {
                return false;
            }
        }
Exemple #2
0
 public void Update(Entry entry)
 {
     using (var repository = new Repository<Entry>())
     {
         var existing = repository.All().Include(x => x.Tags).SingleOrDefault(x => x.Slug == entry.Slug);
         repository.Update(existing,entry);
     }
 }