Esempio n. 1
0
 public ActionResult Create(EntryViewModel entry)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var newEntry = new Entry {Title = entry.Title, EntryBody = entry.EntryBody};
             Blog blog = _blogService.GetBlog(_blogService.GetBlogID((Guid)System.Web.Security.Membership.GetUser().ProviderUserKey));
             newEntry.Blog = blog;
             if (!String.IsNullOrEmpty(entry.Tags))
             {
                 IEnumerable<string> tags = TagEditor.SplitTags(entry.Tags).Distinct();
                 newEntry.Tags = new List<Tag>();
                 foreach (var tag in tags)
                 {
                     var tmp = _tagService.GetTag(tag.Trim());
                     if (tmp == null)
                     {
                         tmp = new Tag
                         {
                             Name = tag.Trim()
                         };
                         _tagService.CreateTag(tmp);
                     }
                     newEntry.Tags.Add(tmp);
                 }
             }
             _entryService.CreateEntry(newEntry);
             return RedirectToAction("Entries", "Blog", new { id = blog.ID });
         }
     }
     catch (DataException)
     {
         ModelState.AddModelError("", "Error! Unable to create entry.");
     }
     return View("Create");
 }
Esempio n. 2
0
 public void UpdateEntry(Entry entry)
 {
     _entryRepository.Update(entry);
 }
Esempio n. 3
0
 public void CreateEntry(Entry entry)
 {
     _entryRepository.Create(entry);
 }