32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using Socialize.Api.Data;
|
|
using Socialize.Api.Modules.Notifications.Contracts;
|
|
using Socialize.Api.Modules.Notifications.Data;
|
|
|
|
namespace Socialize.Api.Modules.Notifications.Services;
|
|
|
|
public class NotificationEventWriter(
|
|
AppDbContext dbContext)
|
|
: INotificationEventWriter
|
|
{
|
|
public async Task WriteAsync(NotificationEventWriteModel model, CancellationToken cancellationToken = default)
|
|
{
|
|
NotificationEvent notificationEvent = new()
|
|
{
|
|
Id = Guid.NewGuid(),
|
|
WorkspaceId = model.WorkspaceId,
|
|
ContentItemId = model.ContentItemId,
|
|
EventType = model.EventType,
|
|
EntityType = model.EntityType,
|
|
EntityId = model.EntityId,
|
|
Message = model.Message,
|
|
RecipientUserId = model.RecipientUserId,
|
|
RecipientEmail = model.RecipientEmail,
|
|
MetadataJson = model.MetadataJson,
|
|
CreatedAt = DateTimeOffset.UtcNow,
|
|
};
|
|
|
|
dbContext.NotificationEvents.Add(notificationEvent);
|
|
await dbContext.SaveChangesAsync(cancellationToken);
|
|
}
|
|
}
|