using Socialize.Api.Data; using Socialize.Api.Modules.ContentItems.Contracts; using Socialize.Api.Modules.ContentItems.Data; namespace Socialize.Api.Modules.ContentItems.Services; internal class ContentItemActivityWriter( AppDbContext dbContext) : IContentItemActivityWriter { public async Task WriteAsync(ContentItemActivityWriteModel model, CancellationToken cancellationToken = default) { ContentItemActivityEntry entry = new() { Id = Guid.NewGuid(), WorkspaceId = model.WorkspaceId, ContentItemId = model.ContentItemId, EventType = model.EventType, EntityType = model.EntityType, EntityId = model.EntityId, Summary = model.Summary, ActorUserId = model.ActorUserId, ActorEmail = model.ActorEmail, MetadataJson = model.MetadataJson, CreatedAt = DateTimeOffset.UtcNow, }; dbContext.ContentItemActivityEntries.Add(entry); await dbContext.SaveChangesAsync(cancellationToken); } }