コード例 #1
0
ファイル: Answer.cs プロジェクト: seranfuen/kotaete
 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;
 }
コード例 #2
0
 private ActionResult GetCommentNotificationPartialView(Comment comment, bool seen)
 {
     var model = GetCommentNotificationModel(comment, seen);
     return PartialView("CommentNotification", model);
 }
コード例 #3
0
 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;
     }
 }
コード例 #4
0
 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;
 }