Esempio n. 1
0
 public async Task <ActionResult> PostActiveRideInRide([FromQuery] string userId, [FromQuery] string activeRideId)
 {
     if (await ActiveRideCenter.UserInRide(activeRideId, userId))
     {
         return(Ok());
     }
     return(BadRequest());
 }
Esempio n. 2
0
        async Task DoneGettingConfirmations()
        {
            IEnumerable <UserRideRequest> passengers = requests;

            lock (requests)
            {
                if (confirmedRideRequests.Count != requests.Count)
                {
                    //Can't just use confirmedRideRequsts because it is unordered; we want to maintain the original ordering.
                    passengers = requests.Where((rr) => confirmedRideRequests.Contains(rr));

                    originalRideModified = true;

                    //Expire the requests of all the others
                    foreach (var rr in requests.Where((r) => !confirmedRideRequests.Contains(r)))
                    {
                        rr.SetExpired();
                        UserTimedOut?.Invoke(rr.User.UserInfo.UserId, false, this);
                    }
                }
            }

            // If all passengers canceled, cancel the offer. If there were no
            // passengers (which should only happen in development), confirm
            // the offer.
            if (!passengers.Any() && requests.Any())
            {
                Cancel();

                return;
            }

            state = PendingRideState.Confirmed;

            if (originalRideModified)
            {
                RideInfo = await rideMatcher.MakeBestRide(offer, passengers);
            }

            //Now we pass the final info to the ActiveRideCenter
            ActiveRideId = await ActiveRideCenter.ActiveRideStarted(RideInfo, offer, confirmedRideRequests);

            PostStatus(0, ActiveRideId).FireAndForgetAsync(Program.ErrorHandler);

            CleanUp();

            StateUpdated?.Invoke(this);
        }