public async Task <ActionResult <IEnumerable <Ride> > > GetRides(string location)
        {
            var rides = await _context.Rides.Include(l => l.Location).ToListAsync();

            foreach (var item in rides.ToList())
            {
                if (item.Location.Name != location)
                {
                    rides.Remove(item);
                }
            }
            rides = rideCompanyFunction.GetFreeCars(rides);
            return(rides);
        }
Пример #2
0
        public async Task <ActionResult <RideCompany> > GetRideCompany(int id)
        {
            var rideCompany = await _context.RideCompanies.Include(r => r.Rides).ThenInclude(l => l.Location).FirstOrDefaultAsync(i => i.ID == id);

            if (rideCompany == null)
            {
                return(NotFound());
            }

            rideCompany.Rating = rideCompanyFunction.calculateRideRating(rideCompany.ID);
            rideCompany.Rides  = rideCompanyFunction.GetFreeCars(rideCompany.Rides);

            return(rideCompany);
        }