Esempio n. 1
0
        static async Task Main(string[] args)
        {
            string date;
            var    channel = GrpcChannel.ForAddress("https://localhost:5001");
            var    client  = new Zodiac.ZodiacClient(channel);

            while (true)
            {
                Console.WriteLine("Introduceti data de nastere:");
                date = Console.ReadLine();
                if (ValidateDate(date))
                {
                    var clientDate = new DateRequest {
                        Date = date
                    };
                    var reply = await client.GetZodiacSignAsync(clientDate);

                    Console.WriteLine("Zodia este: " + reply.Sign);
                    break;
                }
                else
                {
                    Console.WriteLine("Data introdusa nu este valida.");
                }
            }

            Console.WriteLine("Apasati orice tasta pentru a inchide consola.");
            System.Console.ReadKey();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Zodiac.ZodiacClient(channel);

            var cancellationToken = new CancellationTokenSource(Timeout.Infinite);

            while (!cancellationToken.IsCancellationRequested)
            {
                string date = null;

                do
                {
                    Console.WriteLine("Enter date: ");
                    date = Console.ReadLine();
                } while (!Helper.ValidateDate(date));

                var zodiac = new ZodiacObj()
                {
                    Date = date != null && date.Trim().Length > 0 ? date : "Invalid!"
                };
                var answer = client.AddZodiac(new AddZodiacRequest {
                    ZodiacObj = zodiac
                });
                Helper.giveAnswer(answer);
            }
        }
Esempio n. 3
0
        static async Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new Zodiac.ZodiacClient(channel);

            bool enterAnotherDate = true;

            char[] wrongDelimiters = { ' ', '.', '-' };

            do
            {
                string responseToEnterAnotherDate;

                Console.Write("Type in your birthdate in the format: MM/DD/YYYY\n");
                string dateString = Console.ReadLine();
                if (dateString.IndexOfAny(wrongDelimiters) == -1)
                {
                    DateTime date;

                    if (DateTime.TryParse(dateString, out date))
                    {
                        var zodiacToBeFound = new ClientZodiac()
                        {
                            ZodiacDate = Timestamp.FromDateTimeOffset(date)
                        };
                        var response = await client.FindZodiacAsync(new ZodiacRequest { Zodiac = zodiacToBeFound });

                        Console.WriteLine("Your zodiac is: " + response.ZodiacName);

                        enterAnotherDate = false;
                    }
                    else
                    {
                        Console.WriteLine("You have entered an incorrect date. Would you like to try again? Yes or No");
                        responseToEnterAnotherDate = Console.ReadLine();

                        if (responseToEnterAnotherDate != "Yes")
                        {
                            enterAnotherDate = false;
                        }
                    }
                }
                else
                {
                    Console.WriteLine("You used some other delimiters besides '/'. Would you like to try again? Yes or No");
                    responseToEnterAnotherDate = Console.ReadLine();

                    if (responseToEnterAnotherDate != "Yes")
                    {
                        enterAnotherDate = false;
                    }
                }
            } while (enterAnotherDate);
        }
Esempio n. 4
0
 static void Main(string[] args)
 {
     while (true)
     {
         var    channel = GrpcChannel.ForAddress("https://localhost:5001");
         var    client  = new Zodiac.ZodiacClient(channel);
         string input   = InputValidation();
         Console.WriteLine("Zodiac Sign: " + client.GetZodiacSign(new DateRequest {
             Date = input
         }).Sign.ToString());
     }
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new Zodiac.ZodiacClient(channel);

            var request = new DateRequest();

            request.Birthday = ValidateInput();
            var response = client.GetZodiacSign(request);

            Console.WriteLine($"Zodia este {response.Sign}");

            channel.ShutdownAsync().Wait();
            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }