public async Task Update(MicrotingDbContext dbContext) { notifications notification = await dbContext.notifications.SingleOrDefaultAsync(x => x.Id == Id); if (notification == null) { throw new NullReferenceException($"Could not find notification with id {Id}"); } notification.WorkflowState = WorkflowState; notification.MicrotingUid = MicrotingUid; notification.Transmission = Transmission; notification.NotificationUid = NotificationUid; notification.Activity = Activity; notification.Exception = Exception; notification.Stacktrace = Stacktrace; if (dbContext.ChangeTracker.HasChanges()) { notification.UpdatedAt = DateTime.UtcNow; notification.Version += 1; dbContext.notification_versions.Add(MapVersions(notification)); await dbContext.SaveChangesAsync().ConfigureAwait(false); } }
private notification_versions MapVersions(notifications notification) { return(new notification_versions() { WorkflowState = notification.WorkflowState, CreatedAt = notification.CreatedAt, UpdatedAt = notification.UpdatedAt, MicrotingUid = notification.MicrotingUid, Transmission = notification.Transmission, NotificationUid = notification.NotificationUid, Activity = notification.Activity, Exception = notification.Exception, Stacktrace = notification.Stacktrace, NotificationId = notification.Id, Version = notification.Version }); }
public async Task Delete(MicrotingDbContext dbContext) { notifications notification = await dbContext.notifications.SingleOrDefaultAsync(x => x.Id == Id); if (notification == null) { throw new NullReferenceException($"Could not find notification with id {Id}"); } notification.WorkflowState = Constants.Constants.WorkflowStates.Removed; if (dbContext.ChangeTracker.HasChanges()) { notification.UpdatedAt = DateTime.UtcNow; notification.Version += 1; dbContext.notification_versions.Add(MapVersions(notification)); await dbContext.SaveChangesAsync().ConfigureAwait(false); } }