public async Task Handle(CreateEmailNotificationCommand command) { var notification = new EmailNotification(command.NotificationId, command.NotificationType, command.ContactEmail, command.ParticipantId, command.HearingId); _notificationsApiDbContext.Notifications.Add(notification); await _notificationsApiDbContext.SaveChangesAsync(); }
public async Task RemoveNotifications(IEnumerable <Guid> notificationIds) { await using var db = new NotificationsApiDbContext(_dbContextOptions); var notifications = await db.Notifications.Where(x => notificationIds.Contains(x.Id)).ToListAsync(); db.RemoveRange(notifications); await db.SaveChangesAsync(); }
public async Task RemoveNotification(Guid notificationId) { await using var db = new NotificationsApiDbContext(_dbContextOptions); var notification = await db.Notifications.SingleAsync(x => x.Id == notificationId); db.Remove(notification); await db.SaveChangesAsync(); }
public async Task <Notification> SeedNotification(Notification notification) { await using var db = new NotificationsApiDbContext(_dbContextOptions); await db.Notifications.AddAsync(notification); await db.SaveChangesAsync(); return(notification); }
public async Task Handle(UpdateNotificationSentCommand command) { var notification = await _notificationsApiDbContext.Notifications.SingleOrDefaultAsync(x => x.Id == command.NotificationId); if (notification == null) { throw new NotificationNotFoundException(command.NotificationId); } notification.AssignPayload(command.Payload); notification.AssignExternalId(command.ExternalId); notification.UpdateDeliveryStatus(DeliveryStatus.Created); await _notificationsApiDbContext.SaveChangesAsync(); }
public async Task Handle(UpdateNotificationDeliveryStatusCommand command) { var notification = await _notificationsApiDbContext.Notifications.SingleOrDefaultAsync(x => x.Id == command.NotificationId); if (notification == null) { throw new NotificationNotFoundException(command.NotificationId); } if (notification.ExternalId != command.ExternalId) { throw new NotificationIdMismatchException(command.NotificationId, command.ExternalId); } notification.UpdateDeliveryStatus(command.DeliveryStatus); await _notificationsApiDbContext.SaveChangesAsync(); }