public Task PublishedAsync(IKey key) { GuidKey commandKey = key as GuidKey; if (commandKey == null) { throw Ensure.Exception.NotGuidKey(commandKey.GetType(), "key"); } UnPublishedCommandEntity entity = context.UnPublishedCommands.FirstOrDefault(e => e.Command.CommandType == commandKey.Type && e.Command.CommandID == commandKey.Guid); if (entity == null) { return(Task.FromResult(true)); } entity.IsHandled = true; return(context.SaveAsync()); }
public Task PublishedAsync(IKey key, string handlerIdentifier) { GuidKey eventKey = key as GuidKey; if (eventKey == null) { throw Ensure.Exception.NotGuidKey(eventKey.GetType(), "key"); } IEventContext context = contextFactory(); UnPublishedEventEntity entity = context.UnPublishedEvents.FirstOrDefault(e => e.Event.EventType == eventKey.Type && e.Event.EventID == eventKey.Guid); if (entity == null) { return(Task.FromResult(true)); } entity.PublishedToHandlers.Add(new EventPublishedToHandlerEntity(handlerIdentifier)); return(context.SaveAsync()); }