Exemplo n.º 1
0
        private static async Task GetAvailableTicketsForMovie(Cinema.CinemaClient client)
        {
            Console.WriteLine();
            Console.WriteLine("Choose a movieID to know how many tickets are available");
            var movieID = Console.ReadLine();
            var request = new GetAvailableTicketsForMovieRequest();

            request.MovieId = Convert.ToInt32(movieID);
            var response = await client.GetAvailableTicketsForMovieAsync(request);

            Console.WriteLine("There are " + response.AvailableTickets + " tickets available");
        }
Exemplo n.º 2
0
        static async Task Main(string[] args)
        {
            var channel      = CreateAuthenticatedChannel($"https://{Address}");
            var client       = new Alive.AliveClient(channel);
            var cinemaClient = new Cinema.CinemaClient(channel);

            Console.WriteLine("gRPC Ticketer");
            Console.WriteLine();
            Console.WriteLine("Press a key:");
            Console.WriteLine("1: Make a sum");
            Console.WriteLine("2: Get available movies");
            Console.WriteLine("3: Get available Tickets for movie");
            Console.WriteLine("4: Authenticate");
            Console.WriteLine("5: Exit");
            Console.WriteLine();

            var exiting = false;

            while (!exiting)
            {
                var consoleKeyInfo = Console.ReadKey(intercept: true);
                switch (consoleKeyInfo.KeyChar)
                {
                case '1':
                    await MakeASum(client);

                    break;

                case '2':
                    await GetAvailableMovies(cinemaClient);

                    break;

                case '3':
                    await GetAvailableTicketsForMovie(cinemaClient);

                    break;

                case '4':
                    _token = await Authenticate();

                    break;

                case '5':
                    exiting = true;
                    break;
                }
            }

            Console.WriteLine("Exiting");
        }
Exemplo n.º 3
0
        private static async Task GetAvailableMovies(Cinema.CinemaClient client)
        {
            Console.WriteLine();
            Console.WriteLine("Server Call Test");
            Console.WriteLine("Getting available movies...");
            using (var call = client.GetAvailableMovies(new Empty()))
            {
                while (await call.ResponseStream.MoveNext())
                {
                    var currentMovie = call.ResponseStream.Current;

                    Console.WriteLine();
                    Console.WriteLine($"Movie ID : {currentMovie.MovieId}");
                    Console.WriteLine($"Movie Name : {currentMovie.Name}");
                    Console.WriteLine($"Movie Genre : {currentMovie.Genre}");
                    Console.WriteLine($"Movie Duration (minutes) : {currentMovie.Duration}");
                    Console.WriteLine($"Movie Classification : {currentMovie.Classification}");
                    Console.WriteLine($"Number of Tickets For Movie : {currentMovie.NumberOfAvailableTickets}");
                }
            }
        }