public BlogEntry Get(int blogId) { BlogEntry result; using (var context = new EFEntities()) { EFBlogEntry x = context.BlogEntries.Include("Category").SingleOrDefault(y => y.BlogId == blogId); result = new BlogEntry() { BlogId = x.BlogId, DateCreated = x.DateCreated, FullText = x.FullText, Author = x.Author, PreviewText = x.PreviewText, Title = x.Title, Category = new Category() { Id = x.Category.CategoryId, Text = x.Category.CategoryName }, UnprocessedTags = x.TagListString, Tags = new List <string>() }; } result.ConvertUnprocessedToTagList(); return(result); }
public void Add(BlogEntry newBlog) { newBlog.ConvertTagListToUnprocessed(); using (var context = new EFEntities()) { EFBlogEntry forUpdate = context.BlogEntries.SingleOrDefault(p => p.BlogId == newBlog.BlogId); forUpdate.Title = newBlog.Title; forUpdate.FullText = newBlog.FullText; forUpdate.PreviewText = newBlog.PreviewText; forUpdate.TagListString = newBlog.UnprocessedTags; forUpdate.Author = newBlog.Author; forUpdate.Posted = true; context.SaveChanges(); } }
public void AddToQueue(BlogEntry x) { x.ConvertTagListToUnprocessed(); var addResult = new EFBlogEntry() { BlogId = x.BlogId, DateCreated = x.DateCreated, FullText = x.FullText, Author = x.Author, PreviewText = x.PreviewText, Title = x.Title, CategoryId = x.Category.Id, TagListString = x.UnprocessedTags, Posted = false }; using (var context = new EFEntities()) { context.BlogEntries.Add(addResult); context.SaveChanges(); } }