Ejemplo n.º 1
0
        private void OnEntryCommentCreated(IDbTransaction tx, ICommit commit, EntryCommentCreated @event)
        {
            RecordActivity(tx, new Models.Activity {
                UserId = @event.CreatedBy,
                Type   = (int)ActivityType.EntryCommentCreated,
                When   = @event.CreatedAt,
                Link   = $"{commit.AggregateId()},{@event.Id}"
            });

            var author        = new UserDto(_userService.GetUser(@event.CreatedBy, tx));
            var collaborators =
                (_entryService.GetCollaborators(commit.AggregateId())).ToArray()
                .Union(new[] { author })
                .Where(c => c.Id != @event.CreatedBy);

            foreach (var collaborator in collaborators)
            {
                var notification = new Models.EmailNotification {
                    Id          = Guid.NewGuid(),
                    UserId      = @event.CreatedBy,
                    To          = collaborator.Email,
                    When        = @event.CreatedAt,
                    Subject     = $"{author.FirstName} {author.LastName} has made a comment",
                    HtmlBody    = $"<p>{collaborator.FirstName} {collaborator.LastName},</p> <p>Just to let you know {author.FirstName} {author.LastName} has made a new comment on an entry in Folium.</p>",
                    ActionLink  = $"{_applicationConfiguration.Value.BaseUrl}/entries/{commit.AggregateId()}?comment-id={@event.Id}",
                    ActionTitle = "View Entry"
                };
                CreateEmailNotification(tx, notification);
            }
        }
Ejemplo n.º 2
0
 void Apply(EntryCommentCreated @event)
 {
     _comments.Add(@event.Id, new EntryComment {
         Comment   = @event.Comment,
         CreatedAt = @event.CreatedAt,
         CreatedBy = @event.CreatedBy
     });
 }
Ejemplo n.º 3
0
        private void OnEntryCommentCreated(IDbTransaction tx, ICommit commit, EntryCommentCreated @event)
        {
            var sqlParams = @event.ToDynamic();

            sqlParams.EntryId = commit.AggregateId();

            const string sql = @"
				INSERT INTO [dbo].[EntryProjector.EntryComment]
					   ([Id]
					  ,[EntryId]
					  ,[Comment]
					  ,[CreatedBy]
					  ,[CreatedAt])
				 SELECT
					   @Id
					  ,@EntryId
					  ,@Comment
					  ,@CreatedBy
					  ,@CreatedAt
				WHERE NOT EXISTS(SELECT * FROM [dbo].[EntryProjector.EntryComment] WHERE [EntryId] = @EntryId AND [Id] = @Id);"                ;

            tx.Connection.Execute(sql, (object)sqlParams, tx);
        }