private UserPostCommentBM ConvertToBM(UserPostComment model) { return(new UserPostCommentBM() { Id = model.Id, UserId = model.UserId, Comment = model.Comment, PostId = model.PostId, CreatedBy = model.CreatedBy, CreationDate = model.CreationDate, ModifiedBy = model.ModifiedBy, ModificationDate = model.ModificationDate }); }
public static void CommentToUserPost(int fromUserId, int toUserPostId, string content) { var context = new SocialNetworkContext(); var sender = context.Users.Find(fromUserId); var userPost = context.UserPosts.Find(toUserPostId); var comment = new UserPostComment() { Content = content, Author = sender, PostedOn = DateTime.Now, UserPost = userPost }; context.UserPostComments.Add(comment); context.SaveChanges(); }