コード例 #1
0
 public CommentNotification(
     Comment comment,
     IDataContext context)
 {
     this.comment = comment;
     this.context = context;
 }
コード例 #2
0
ファイル: CommentMapper.cs プロジェクト: vbogretsov/academy
 public static CommentViewModel Map(Comment model)
 {
     var viewModel = mapper.Map(model);
     viewModel.AuthorId = model.UserId;
     viewModel.Author = AuthorMapper.Map(model.User);
     viewModel.ArticleId = model.ArticleId;
     return viewModel;
 }
コード例 #3
0
ファイル: AcademyService.cs プロジェクト: vbogretsov/academy
 public void NotifyAboutNewComment(Comment comment)
 {
     throw new NotSupportedException();
 }
コード例 #4
0
ファイル: AcademyService.cs プロジェクト: vbogretsov/academy
 public void Comment(Comment comment)
 {
     comment.UserId = GetCurrentUser().Id;
     PublicationService.Comment(comment);
     NotificationService.NotifyAboutNewComment(comment);
 }
コード例 #5
0
 public static CommentViewModel Map(Comment comment)
 {
     CommentViewModel viewModel = CommentMapper.Map(comment);
     viewModel.Article = ArticleSmallMapper.Map(comment.Article);
     return viewModel;
 }
コード例 #6
0
 public void Comment(Comment comment)
 {
     comment.PostedDate = DateTime.Now;
     commentStorage.Add(comment);
 }
コード例 #7
0
 public void Add(Comment comment)
 {
     Add(comment, Entities.Comments);
 }
コード例 #8
0
 private void AddComments(IEntity article, string articleInfo)
 {
     var comments = Regex.Matches(articleInfo, "(?<=text:).*");
     var authors = Regex.Matches(articleInfo, "(?<=author:).*");
     for (int i = 0; i < comments.Count; i++)
     {
         var comment = new Comment();
         comment.ArticleId = article.Id;
         comment.Text = comments[i].Value;
         using (var academyEntities = new AcademyEntities())
         {
             var email = authors[i].Value.TrimEnd('\r');
             comment.UserId = academyEntities.Users.Single(
                 x => x.Email.Equals(email)).Id;
         }
         using (var context = new EfDataContext())
         {
             var publicationService = new PublicationService(context);
             publicationService.Comment(comment);
             var notificationService = new NotificationService(context);
             notificationService.NotifyAboutNewComment(comment);
         }
     }
 }