private void OnEntryCreated(IDbTransaction tx, ICommit commit, EntryCreated @event) { var sqlParams = @event.ToDynamic(); sqlParams.Id = commit.AggregateId(); // Record who created the entry so it can be used when it is updated. const string sql = @" INSERT INTO [dbo].[ActivityProjector.Entry] ([EntryId] ,[UserId]) SELECT @Id ,@UserId WHERE NOT EXISTS(SELECT * FROM [dbo].[ActivityProjector.Entry] WHERE [EntryId] = @Id);" ; tx.Connection.Execute(sql, (object)sqlParams, tx); RecordActivity(tx, new Models.Activity { UserId = @event.UserId, Type = (int)ActivityType.EntryCreated, When = @event.CreatedAt, Link = commit.AggregateId().ToString() }); }
private void OnEntryCreated(IDbTransaction tx, ICommit commit, EntryCreated @event) { var sqlParams = @event.ToDynamic(); sqlParams.Id = commit.AggregateId(); const string sql = @" INSERT INTO [dbo].[PlacementProjector.Entry] ([Id] ,[PlacementId] ,[SkillSetId] ,[Title] ,[Description] ,[UserId] ,[Where] ,[When] ,[Shared]) SELECT TOP 1 @Id ,Id ,@SkillSetId ,@Title ,@Description ,@UserId ,[FullyQualifiedTitle] ,@When ,0 -- Not shared FROM [PlacementProjector.Placement] WHERE [FullyQualifiedTitle] = @Where AND [UserId] = @UserId AND NOT EXISTS(SELECT * FROM [dbo].[PlacementProjector.Entry] WHERE Id = @Id);" ; tx.Connection.Execute(sql, (object)sqlParams, tx); }
private void OnEntryCreated(IDbTransaction tx, ICommit commit, EntryCreated @event) { var sqlParams = @event.ToDynamic(); sqlParams.Id = commit.AggregateId(); const string sql = @" INSERT INTO [dbo].[EntryProjector.Entry] ([Id] ,[SkillSetId] ,[Title] ,[Description] ,[UserId] ,[Where] ,[When] ,[CreatedAt] ,[LastUpdatedAt] ,[Shared]) SELECT @Id ,@SkillSetId ,@Title ,@Description ,@UserId ,@Where ,@When ,@CreatedAt ,@LastUpdatedAt ,0 -- Not shared WHERE NOT EXISTS(SELECT * FROM [dbo].[EntryProjector.Entry] WHERE Id = @Id);" ; tx.Connection.Execute(sql, (object)sqlParams, tx); }
private void OnEntryCreated(IDbTransaction tx, ICommit commit, EntryCreated @event) { var sqlParams = @event.ToDynamic(); sqlParams.Id = commit.AggregateId(); const string sql = @" INSERT INTO [dbo].[WhereProjector.Entry] ([EntryId] ,[UserId] ,[Where]) SELECT @Id ,@UserId ,@Where WHERE NOT EXISTS(SELECT * FROM [dbo].[WhereProjector.Entry] WHERE [EntryId] = @Id);" ; tx.Connection.Execute(sql, (object)sqlParams, tx); CreateWhereProjection(tx, @event.UserId, @event.Where); }