Beispiel #1
0
        /// <summary>
        /// Unsubscribe form the event type T
        /// </summary>
        /// <param name="guid">Subscription guid</param>
        /// <typeparam name="T">Event type</typeparam>
        /// <typeparam name="TH"></typeparam>
        /// <returns>Result</returns>
        public bool Unsubscribe <T, TH>(string guid)
            where T : IntegrationEvent
            where TH : IIntegrationEventHandler <T>
        {
            if (!_subscriptionsManager.HasEventTopic <T>() || !_subscriptionsManager.HasSubscription <T>(guid))
            {
                return(false);
            }

            var model = _integrationEventsRespository.SetModelAsync <T, TH>(false);

            if (model == null)
            {
                throw new Exception($"Error on usubscription to the integration event {typeof(T).Name}");
            }

            _subscriptionsManager.RemoveSubscription <T>(guid);

            return(!_subscriptionsManager.HasSubscription <T>(guid));
        }