Exemplo n.º 1
0
 public string Add(Blog blog)
 {
     _context.Blogs.Add(blog);
     _context.SaveChanges();
     _context.Dispose();
     return string.Empty;
 }
Exemplo n.º 2
0
 public BlogSiteViewModel MapToView(Blog blog)
 {
     BlogSiteViewModel view = Mapper.Map<Blog, BlogSiteViewModel>(blog);
     if (view.HtmlFragments == null) view.HtmlFragments = new List<HtmlFragmentViewModel>();
     foreach (var htmlFragment in blog.HtmlFragments)
     {
         var html = _htmlFragmentMappingService.MapToView(htmlFragment);
         if (!view.HtmlFragments.Any(x => x.Id == htmlFragment.Id)) view.HtmlFragments.Add(html);
     }
     return view;
 }
Exemplo n.º 3
0
 public string Save(Blog blog)
 {
     var temp = _context.Blogs.FirstOrDefault(x => x.Id == blog.Id);
     if (temp == null) return "The specified blog could not be found.";
     temp.BlogName = blog.BlogName;
     temp.HostName = blog.HostName;
     temp.IsActive = blog.IsActive;
     temp.IsPrimary = blog.IsPrimary;
     temp.SubHead = blog.SubHead;
     _context.SaveChanges();
     _context.Dispose();
     return string.Empty;
 }