Beispiel #1
0
        public async Task Subscribe(params String[] mediaNames)
        {
            if (mediaNames == null || mediaNames.Length < 1)
            {
                await Context.Channel.SendMessageAsync("Nothing to do.");
            }
            var notificationEndpointNotifierIdentifier = GetNotificationEndpointNotifierIdentifier(Context);
            var notificationEndpointResult             = await _notificationEndpointService.AddNotificationEndpoint(new NotificationEndpoint(notificationEndpointNotifierIdentifier, new List <Subscription>()), CancellationToken.None);

            var message = "Something went wrong";

            if (notificationEndpointResult.IsSuccess)
            {
                var subscriptions = mediaNames
                                    .Select(mediaName => new Subscription(mediaName, notificationEndpointNotifierIdentifier))
                                    .ToList();

                var result = await _subscriptionService.AddSubscriptions(subscriptions, CancellationToken.None);

                if (result.All(r => r.IsSuccess))
                {
                    message = "Successfully subscribed";
                }
            }
            await Context.Channel.SendMessageAsync(message);
        }