Пример #1
0
        public async Task <IEnumerable <TravelsResponse> > GetTravels(string userMail)
        {
            var response = await TravelRepository.GetTravels(userMail);

            var travelsList = new List <TravelsResponse>();

            foreach (var travel in response)
            {
                var location = await LocationRepository.GetLocation(travel.TravelId);

                travelsList.Add(TravelConverter.ToDomainTravel(travel, location));
            }
            return(travelsList);
        }
        public ActionResult <IEnumerable <Travel> > GetTravels(int userId)
        {
            List <Travel> travels = new List <Travel>();

            try{
                travels = TravelRepository.GetTravels(userId);
                return(Ok(travels));
            }catch (WithoutExistenceOfTravelsException ex) {
                return(StatusCode(404, ex.Message));
            }catch (UserNotFoundException ex) {
                return(StatusCode(400, ex.Message));
            }catch (InternalServerErrorException ex) {
                return(StatusCode(500, ex.Message));
            }catch (Exception) {
                return(StatusCode(400));
            }
        }
Пример #3
0
        public void GetTravelSuccessfully()
        {
            List <Travel> listOfTravels = TravelRepository.GetTravels(5); //Usuario cliente

            Assert.NotZero(listOfTravels.Count);
        }
Пример #4
0
 public void WithoutExistenceOfTravelsException()
 {
     Assert.Throws <WithoutExistenceOfTravelsException>(
         () => TravelRepository.GetTravels(1)); //Usuario administrador
 }
Пример #5
0
 public void UserNotFoundException()
 {
     Assert.Throws <UserNotFoundException>(
         () => TravelRepository.GetTravels(1000));
 }