private void detach_BlogPost_Likers(BlogPost_Liker entity) { this.SendPropertyChanging(); entity.BlogPost = null; }
partial void DeleteBlogPost_Liker(BlogPost_Liker instance);
partial void InsertBlogPost_Liker(BlogPost_Liker instance);
partial void UpdateBlogPost_Liker(BlogPost_Liker instance);
/// <summary> /// Likes a user's blog post. /// </summary> /// <param name="postID">The blog post to like</param> /// <returns>Refreshes the page.</returns> public ActionResult LikeBlog(int postID) { BlogPost_Liker newLiker = new BlogPost_Liker(); newLiker.BlogPostId = postID; newLiker.UserId = WebSecurity.CurrentUserId; if (!db.BlogPost_Likers.Contains(newLiker)) { db.BlogPost_Likers.InsertOnSubmit(newLiker); var blogPost = (from blogs in db.BlogPosts where blogs.BlogPostId == postID select blogs).FirstOrDefault(); blogPost.LikeCount++; db.SubmitChanges(); var likerUserName = (from userprofiles in userDb.UserProfiles where userprofiles.UserId == newLiker.UserId select userprofiles.UserName).FirstOrDefault(); var userID = (from blogs in db.BlogPosts where blogs.BlogPostId == postID select blogs.UserId).FirstOrDefault(); SendSMS(userID, likerUserName + " has liked one of your posts. Come visit Cookbook and check out which post " + likerUserName + " liked!"); SendEmail(userID, likerUserName + " has liked one of your posts.", likerUserName + " has liked one of your posts. Come visit Cookbook and check out which post " + likerUserName + " liked!"); } return Redirect(Request.UrlReferrer.AbsoluteUri); }