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); } } }
public void Comment(Comment comment) { comment.UserId = GetCurrentUser().Id; PublicationService.Comment(comment); NotificationService.NotifyAboutNewComment(comment); }