public static BlogEntryCategory GetFakeBlogEntryCategory(long blogEntryId, int blogCategoryId) { var blogEntryCategory = new BlogEntryCategory() { BlogCategoryId = blogCategoryId, BlogEntryId = blogEntryId, CreateDate = DateTime.Now }; return blogEntryCategory; }
/// <summary> /// Deprecated Method for adding a new object to the BlogEntryCategories EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBlogEntryCategories(BlogEntryCategory blogEntryCategory) { base.AddObject("BlogEntryCategories", blogEntryCategory); }
/// <summary> /// Create a new BlogEntryCategory object. /// </summary> /// <param name="blogEntryCategoryId">Initial value of the BlogEntryCategoryId property.</param> /// <param name="blogEntryId">Initial value of the BlogEntryId property.</param> /// <param name="blogCategoryId">Initial value of the BlogCategoryId property.</param> /// <param name="createDate">Initial value of the CreateDate property.</param> public static BlogEntryCategory CreateBlogEntryCategory(global::System.Int64 blogEntryCategoryId, global::System.Int64 blogEntryId, global::System.Int32 blogCategoryId, global::System.DateTime createDate) { BlogEntryCategory blogEntryCategory = new BlogEntryCategory(); blogEntryCategory.BlogEntryCategoryId = blogEntryCategoryId; blogEntryCategory.BlogEntryId = blogEntryId; blogEntryCategory.BlogCategoryId = blogCategoryId; blogEntryCategory.CreateDate = createDate; return blogEntryCategory; }
string IMetaWeblog.AddPost(string blogid, string username, string password, Post post, bool publish) { if (ValidateUser(username, password)) { string id = string.Empty; //using (VeritasDataContext con = new VeritasDataContext()) VeritasRepository repo = VeritasRepository.GetInstance(); BlogUser user = repo.GetBlogUserByUserName(CacheHandler.BlogConfigId, username); //Check to see if the entry name exists: //if (repo.DoesEntryTitleExist(post.title, post.title.Replace(";", "-").Replace(" ", "-").Replace(".", "-").Replace("?", "-").Replace("%", "-"), CacheAccessor.GetBlogConfigID())) if (repo.DoesEntryTitleExist(CacheHandler.BlogConfigId, post.title, HttpUtility.HtmlEncode(post.title))) { throw new XmlRpcFaultException(0, "The title you have tried already exists for this blog."); } BlogEntry entry = new BlogEntry(); entry.BlogConfigId = CacheHandler.BlogConfigId; entry.BlogAuthorId = user.BlogUserId; entry.EntryName = EntryTitleLogic.GetEntryNameFromTitle(HttpUtility.HtmlDecode(post.title)); entry.FeedbackCount = 0; entry.PostType = publish ? (int)PostType.Published : (int)PostType.Draft; if (post.dateCreated.Year > 0001) entry.PublishDate = post.dateCreated; else entry.PublishDate = DateTime.Now; //entry.Text = post.description; entry.Text = HighSlideHandler.UpdateLiveWriterImagesWithHighslide(post.description); entry.Title = HttpUtility.HtmlDecode(post.title); entry.LastUpdateDate = DateTime.Now; entry.CreateDate = DateTime.Now; //id = con.SaveBlogEntry(entry).ToString(); repo.Add(entry); repo.Save(); id = entry.BlogEntryId.ToString(); BlogConfig config = repo.GetBlogConfigByBlogConfigId(entry.BlogConfigId); config.PostCount++; repo.Save(); BlogEntryCategory entCat = new BlogEntryCategory(); repo.SaveEntryCategoryAssociation(entry.BlogConfigId, entry.BlogEntryId, post.categories); //Save Blog Entry View var existingViewCount = repo.GetBlogEntryViewCountByEntryId(entry.BlogEntryId); if (existingViewCount == null) { BlogEntryViewCount entryViewCount = new BlogEntryViewCount() { BlogConfigId = entry.BlogConfigId, BlogEntryId = entry.BlogEntryId, WebCount = 0, WebLastUpdated = DateTime.Now }; repo.Add(entryViewCount); repo.Save(); } return id; } throw new XmlRpcFaultException(0, "User is not valid!"); }
public void Add(BlogEntryCategory blogEntryCategory) { db.BlogEntryCategories.AddObject(blogEntryCategory); }
public void SaveEntryCategoryAssociation(int blogConfigId, long blogEntryId, string[] categoryNames) { List<BlogEntryCategory> assocs = db.BlogEntryCategories.Where(p => p.BlogEntryId == blogEntryId).ToList(); foreach (var item in assocs) db.BlogEntryCategories.DeleteObject(item); this.Save(); assocs = new List<BlogEntryCategory>(); foreach (string categoryName in categoryNames) { BlogCategory category = db.BlogCategories.Where(p => p.BlogConfigId == blogConfigId) .Where(p => p.Title == categoryName).SingleOrDefault(); if (category != null) { BlogEntryCategory assoc = new BlogEntryCategory(); assoc.BlogEntryId = blogEntryId; assoc.BlogCategoryId = category.BlogCategoryId; assoc.CreateDate = DateTime.Now; assocs.Add(assoc); } } foreach (var item in assocs) db.BlogEntryCategories.AddObject(item); this.Save(); }
public void Delete(BlogEntryCategory blogEntryCategory) { db.BlogEntryCategories.DeleteObject(blogEntryCategory); }
public void GetEntriesForCategoryFromStartPointTest() { var blogEntry = new BlogEntry() { BlogConfigId = TestBlogConfig.BlogConfigId, BlogAuthorId = TestBlogUser.BlogUserId, CreateDate = DateTime.Now, EntryName = "Test2", FeedbackCount = 0, Keywords = "", LastUpdateDate = DateTime.Now, PostType = (int)PostType.Published, PublishDate = DateTime.Now, Short = "Test2", Text = "Test2", Title = "Test2" }; repo.Add(blogEntry); repo.Save(); var blogEntryCategory = new BlogEntryCategory() { BlogCategoryId = TestBlogCategory.BlogCategoryId, BlogEntryId = blogEntry.BlogEntryId, CreateDate = DateTime.Now }; repo.Add(blogEntryCategory); repo.Save(); var recentEntries = repo.GetEntriesForCategoryFromStartPoint(TestBlogConfig.BlogConfigId, 2, 0, TestBlogCategory.Title).ToArray(); Assert.IsNotNull(recentEntries); Assert.IsTrue(recentEntries.Length == 2); var recentEntries2 = repo.GetEntriesForCategoryFromStartPoint(TestBlogConfig.BlogConfigId, 2, 1, TestBlogCategory.Title).ToArray(); Assert.IsNotNull(recentEntries2); Assert.IsTrue(recentEntries2.Length == 1); }