public Comment AddComment(ApplicationUser user, string content) { var comment = new Comment() { Answer = this, AnswerId = AnswerId, User = user, UserId = user.Id, Content = content, Active = true, TimeStamp = DateTime.Now.AddDays((new Random()).Next(0, 15)) }; Comments.Add(comment); return comment; }
private ActionResult GetCommentNotificationPartialView(Comment comment, bool seen) { var model = GetCommentNotificationModel(comment, seen); return PartialView("CommentNotification", model); }
private CommentNotificationViewModel.CommentNotificationTypeEnum GetCommentNotificationType(Comment comment) { if (IsCurrentUser(comment.Answer.User) && !IsCurrentUser(comment.User)) { return CommentNotificationViewModel.CommentNotificationTypeEnum.CurrentUserAnswer; } else if (IsCurrentUser(comment.Answer.QuestionDetail.AskedBy.UserName) && !IsCurrentUser(comment.User)) { return CommentNotificationViewModel.CommentNotificationTypeEnum.CurrentUserAskedQuestion; } else if (comment.User == comment.Answer.User) { return CommentNotificationViewModel.CommentNotificationTypeEnum.CommentingUserIsAnsweringUser; } else { return CommentNotificationViewModel.CommentNotificationTypeEnum.CurrentUserCommentedAnswer; } }
private CommentNotificationViewModel GetCommentNotificationModel(Comment comment, bool seen) { var type = GetCommentNotificationType(comment); var model = new CommentNotificationViewModel(comment, seen) { AnswerId = comment.AnswerId, AnsweringUser = GetProfileFor(comment.Answer.User), CommentingUser = GetProfileFor(comment.User), CommentNotificationType = type, TimeStamp = comment.TimeStamp }; return model; }