Exemple #1
0
        private async Task CreateEmailSubscriptionAsync()
        {
            try
            {
                Console.Write("Enter a topic name: ");
                var topicName = Console.ReadLine();

                Console.Write("Enter an email: ");
                var email = Console.ReadLine();

                var subscription = await _subscriptionService.CreateEmailSubscriptionAsync(topicName, email);

                Console.WriteLine(JsonConvert.SerializeObject(subscription, Formatting.Indented));
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ErrorForegroundColor;
                Console.WriteLine(e);
                Console.ForegroundColor = ForegroundColor;
            }
        }
        private async Task CreateEmailSubscriptionAsync()
        {
            try
            {
                Console.Write("Enter a topic name: ");
                var topicName = Console.ReadLine() ?? string.Empty;

                Console.Write("Enter an email: ");
                var email = Console.ReadLine() ?? string.Empty;

                var subscription = await _subscriptionService.CreateEmailSubscriptionAsync(topicName, email);

                Console.WriteLine(JsonSerializer.Serialize(subscription, new JsonSerializerOptions {
                    WriteIndented = true
                }));
            }
            catch (Exception e)
            {
                Console.ForegroundColor = ErrorForegroundColor;
                Console.WriteLine(e);
                Console.ForegroundColor = ForegroundColor;
            }
        }