public async Task Handle(EditStatusEventManualChangeEntity entity) { var eventRowKey = EventEntity.GetRowKey(entity.EventAffectedComponentPath, entity.EventStartTime); var eventEntity = await _table.RetrieveAsync <EventEntity>(eventRowKey); if (eventEntity == null) { throw new ArgumentException("Cannot edit an event that does not exist."); } eventEntity.AffectedComponentStatus = entity.EventAffectedComponentStatus; ManualStatusChangeUtility.UpdateEventIsActive(eventEntity, entity.EventIsActive, entity.Timestamp.UtcDateTime); await _table.ReplaceAsync(eventEntity); }
public async Task Handle(AddStatusMessageManualChangeEntity entity) { var time = entity.Timestamp.UtcDateTime; var eventRowKey = EventEntity.GetRowKey(entity.EventAffectedComponentPath, entity.EventStartTime); var eventEntity = await _table.RetrieveAsync <EventEntity>(eventRowKey); if (eventEntity == null) { throw new ArgumentException("Cannot create a message for an event that does not exist."); } var messageEntity = new MessageEntity(eventEntity, time, entity.MessageContents, MessageType.Manual); await _table.InsertAsync(messageEntity); if (ManualStatusChangeUtility.UpdateEventIsActive(eventEntity, entity.EventIsActive, time)) { await _table.ReplaceAsync(eventEntity); } }