public static CommentModel CommentToCommentModel(Comment comment) { if (comment != null) { CommentModel commentModel = new CommentModel(); commentModel.CommentId = comment.CommentId; commentModel.UserProfileId = comment.UserProfileId; commentModel.EventId = comment.EventId; commentModel.CommentText = comment.CommentText; commentModel.Timestamp = comment.Timestamp; return commentModel; } else { return null; } }
public bool UpdateComment(CommentModel updateCommentModel) { Comment comment = db.Comments.Where(c => c.CommentId == updateCommentModel.CommentId).FirstOrDefault(); if (comment != null) { comment.CommentText = updateCommentModel.CommentText; comment.Timestamp = DateTime.Now; db.SaveChanges(); return true; } else { return false; } }