Beispiel #1
0
        //Methods
        private async Task GetCurrentTrip()
        {
            this.Loading = true;
            RaisePropertyChanged("Loading");

            await Task.Run(async() =>
            {
                Trip currenttrip = Task.FromResult <Trip>(await TripRepository.GetCurrentTrip()).Result;
                if (currenttrip != null)
                {
                    if (currenttrip.Active == true)
                    {
                        Trip.All trips_all = new Trip.All();


                        User.All user = await UsersRepository.GetUserById(currenttrip.Users_ID);
                        Bob.All bob   = await BobsRepository.GetBobById(currenttrip.Bobs_ID);
                        Users_Destinations destination = await DestinationRepository.GetDestinationById((currenttrip.Destinations_ID));
                        Party party      = await PartyRepository.GetPartyById(currenttrip.Party_ID);
                        Trip.All newTrip = new Trip.All();



                        newTrip.Trip        = currenttrip;
                        newTrip.Party       = party;
                        newTrip.User        = user;
                        newTrip.Bob         = bob;
                        newTrip.Destination = destination;

                        MoveCar(newTrip.Trip.Status_Name);
                        this.CurrentTrip = newTrip;
                    }
                    else
                    {
                        this.CurrentTrip = null;
                        //geen current trip nu
                    }
                }
                RaiseAll();
            });
        }
Beispiel #2
0
        private async Task GetTrips()
        {
            bool canRun = true;

            this.Loading = true;
            RaisePropertyChanged("Loading");

            await Task.Run(async() =>
            {
                List <Trip> trips = await TripRepository.GetTrips();

                trips_all = new List <Trip.All>();

                if (trips == null || trips.Count == 0)
                {
                    this.Error   = "Geen trips gevonden";
                    canRun       = false;
                    this.Loading = false;
                    RaiseAll();
                    return;
                }

                var count = trips.Count;
                if ((trips.Count >= 10) && canRun == true)
                {
                    count = 10;
                }

                for (int i = 0; i < count; i++)
                {
                    Task <User.All> user = Task.FromResult <User.All>(await UsersRepository.GetUserById(trips[i].Users_ID));
                    Task <Bob.All> bob   = Task.FromResult <Bob.All>(await BobsRepository.GetBobById(trips[i].Bobs_ID));
                    Task <Users_Destinations> destination = Task.FromResult <Users_Destinations>(await DestinationRepository.GetDestinationById((trips[i].Destinations_ID)));
                    Task <Party> party = Task.FromResult <Party>(await PartyRepository.GetPartyById(trips[i].Party_ID));
                    Trip.All newTrip   = new Trip.All();


                    newTrip.Trip        = trips[i];
                    newTrip.User        = user.Result;
                    newTrip.Bob         = bob.Result;
                    newTrip.Party       = party.Result;
                    newTrip.Destination = destination.Result;
                    trips_all.Add(newTrip);
                }


                this.Trips   = trips_all;
                canRun       = false;
                this.Loading = false;


                RaiseAll();
            });
        }