Exemplo n.º 1
0
        static async Task GetAll(TripClient tripClient)
        {
            Console.WriteLine("Get all");
            List <Trip> trips = await tripClient.GetAll();

            trips.ForEach(Console.WriteLine);
        }
Exemplo n.º 2
0
        static async Task Add(TripClient tripClient)
        {
            Console.WriteLine("Add");
            Trip trip = await tripClient.Add(new Trip(-1, "merge", "a", DateTime.Now, (float)10.0, 20));

            Console.WriteLine(trip);
            await GetAll(tripClient);
        }
Exemplo n.º 3
0
        private static async Task RunAsync()
        {
            TripClient tripClient = new TripClient("http://localhost:8080/trips/");

            await GetById(tripClient);
            await GetAll(tripClient);
            await Add(tripClient);
            await Update(tripClient);
            await Delete(tripClient);
        }
Exemplo n.º 4
0
        static async Task GetById(TripClient tripClient)
        {
            try
            {
                Console.WriteLine("Get by id");
                Trip trip = await tripClient.GetById(1);

                Console.WriteLine(trip);
            }
            catch (ServiceException se)
            {
                Console.WriteLine(se.Message);
            }
        }
Exemplo n.º 5
0
        private static async Task Delete(TripClient tripClient)
        {
            try
            {
                Console.WriteLine("Delete");
                List <Trip> trips = await tripClient.GetAll();

                Trip trip   = trips[trips.Count - 1];
                Trip result = await tripClient.Delete(trip.Id);

                Console.WriteLine(result);
                await GetAll(tripClient);
            }
            catch (ServiceException se)
            {
                Console.WriteLine(se.Message);
            }
        }
Exemplo n.º 6
0
        private static async Task Update(TripClient tripClient)
        {
            try
            {
                Console.WriteLine("Update");
                List <Trip> trips = await tripClient.GetAll();

                Trip trip = trips[trips.Count - 1];
                trip.Landmark = "updatedLandmark";
                Trip result = await tripClient.Update(trip);

                Console.WriteLine(result);
                await GetAll(tripClient);
            }
            catch (ServiceException se)
            {
                Console.WriteLine(se.Message);
            }
        }