Exemplo n.º 1
0
        public IHttpActionResult Get(string username)
        {
            if (!Repository.Instance.UserExists(username))
            {
                return(NotFound());
            }

            var user = Repository.Instance.TaxiServiceRepository.Users.FirstOrDefault(x => x.Username == username);
            IEnumerable <RideResponse> rides;

            switch (user.Role)
            {
            case UserRole.Customer:
            {
                var ridesAllData = Repository.Instance.TaxiServiceRepository.GetAllRides().Where(x => x.CustomerId == user.Id).ToList();
                rides = ridesAllData.Select(x => RideResponse.Convert(x));
            }
            break;

            case UserRole.Driver:
            {
                var ridesAllData = Repository.Instance.TaxiServiceRepository.GetAllRides().Where(x => x.DriverId == user.Id).ToList();
                rides = ridesAllData.Select(x => RideResponse.Convert(x));
            }
            break;

            case UserRole.Dispatcher:
            {
                var ridesAllData = Repository.Instance.TaxiServiceRepository.GetAllRides().Where(x => x.DispatcherId == user.Id).ToList();
                rides = ridesAllData.Select(x => RideResponse.Convert(x));
            }
            break;

            default:
                rides = null;
                break;
            }

            return(Ok(rides));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns basic ride data in compliance with GDPR
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public RideResponse Get(int id)
        {
            var ride = Repository.Instance.TaxiServiceRepository.GetAllRides().FirstOrDefault(x => x.Id == id);

            return(RideResponse.Convert(ride));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Collection of rides converted to return just basic user information in compliance with GDPR
 /// </summary>
 /// <returns></returns>
 public IEnumerable <RideResponse> Get()
 {
     return(Repository.Instance.TaxiServiceRepository.GetAllRides().ToList().Select(x => RideResponse.Convert(x)));
 }