/// <summary> /// Elimina un readmodel /// ?? gestire un flag di eliminato e memorizzare l'id dell'evento?? /// </summary> /// <param name="e"></param> /// <param name="id"></param> /// <param name="notify"></param> public void Delete(DomainEvent e, TKey id, bool notify = false) { string[] topics = null; if (NotifySubscribers && typeof(ITopicsProvider).IsAssignableFrom(typeof(TModel))) { var model = _storage.FindOneById(id); if (model == null) { return; } topics = ((ITopicsProvider)model).GetTopics().ToArray(); } var result = _storage.Delete(id); if (!result.Ok) { throw new Exception(string.Format("Delete error on {0} :: {1}", typeof(TModel).FullName, id)); } if (result.DocumentsAffected == 1) { if (!IsReplay && (notify || NotifySubscribers)) { _notifyToSubscribers.Send(ReadModelUpdatedMessage.Deleted <TModel, TKey>(id, topics)); } } }