Beispiel #1
0
        public async Task <bool> Book(BookFlightDto bookFlight, InformationProvider informationProvider)
        {
            //Obtiene la información de metadata y la lleva al modelo de metadata
            var metadataCofig = await _repository.GetMetadata(informationProvider, IMetadataRestRepository.RequestType.book);

            if (metadataCofig.Body != null || metadataCofig.Body != "")
            {
                var metadataFieldTransport = Newtonsoft.Json.JsonConvert.DeserializeObject <Entity.Transport.BookFlightDto>(metadataCofig.Body);
                //Convierte el objeto request en Json
                var body = Newtonsoft.Json.JsonConvert.SerializeObject(bookFlight, Newtonsoft.Json.Formatting.Indented);
                metadataCofig.Body = _fieldMapper.GetBodyMapped(metadataFieldTransport, body);
            }

            metadataCofig.Url = _fieldMapper.GetUrlMapped(bookFlight, metadataCofig.Url);
            var providerConsumer = new ProviderConsumerService(_consumer);

            var result = await providerConsumer.Request(metadataCofig);

            if (!result.IsSuccessStatusCode)
            {
                throw new ProviderNotResponseException();
            }

            var value = await result.Content.ReadAsStringAsync();

            if (bool.TryParse(value, out bool finalBook))
            {
                return(finalBook);
            }

            return(true);
        }
Beispiel #2
0
        public async Task <List <RoomDto> > Search(SearchRoomDto searchRoom, InformationProvider informationProvider)
        {
            //Obtiene la información de metadata y la lleva al modelo de metadata
            var metadataCofig = await _repository.GetMetadata(informationProvider, IMetadataRestRepository.RequestType.search);

            if (metadataCofig.Body != null || metadataCofig.Body != "")
            {
                var metadataFieldTransport = Newtonsoft.Json.JsonConvert.DeserializeObject <Entity.Hotel.SearchRoomDto>(metadataCofig.Body);
                //Convierte el objeto request en Json
                var body = Newtonsoft.Json.JsonConvert.SerializeObject(searchRoom, Newtonsoft.Json.Formatting.Indented);
                metadataCofig.Body = _fieldMapper.GetBodyMapped(metadataFieldTransport, body);
            }
            metadataCofig.Url = _fieldMapper.GetUrlMapped(searchRoom, metadataCofig.Url);
            var providerConsumer = new ProviderConsumerService(_consumer);
            var result           = await providerConsumer.Request(metadataCofig);

            if (!result.IsSuccessStatusCode)
            {
                throw new ProviderNotResponseException();
            }

            var response = await result.Content.ReadAsStringAsync();

            var rooms = _fieldMapper.GetObjetMapped <List <RoomDto> >(response, metadataCofig.Response);

            return(rooms);
        }
Beispiel #3
0
        public async Task <List <TripDto> > Search(SearchFlightDto searchFlight, DomainModel.Dto.InformationProvider informationProvider)
        {
            //Obtiene la información de metadata y la lleva al modelo de metadata
            var metadataCofig = await _repository.GetMetadata(informationProvider, IMetadataRestRepository.RequestType.search);

            if (metadataCofig.Body != null || metadataCofig.Body != "")
            {
                var metadataFieldTransport = Newtonsoft.Json.JsonConvert.DeserializeObject <Entity.Transport.SearchFlightDto>(metadataCofig.Body);
                //Convierte el objeto request en Json
                var body = Newtonsoft.Json.JsonConvert.SerializeObject(searchFlight, Newtonsoft.Json.Formatting.Indented);
                metadataCofig.Body = _fieldMapper.GetBodyMapped(metadataFieldTransport, body);
            }

            metadataCofig.Url = _fieldMapper.GetUrlMapped(searchFlight, metadataCofig.Url);
            var providerConsumer = new ProviderConsumerService(_consumer);
            var result           = await providerConsumer.Request(metadataCofig);

            if (!result.IsSuccessStatusCode)//Respondió de manera
            {
                throw new ProviderNotResponseException();
            }

            var trips    = new List <TripDto>();
            var response = await result.Content.ReadAsStringAsync();


            var fly = _fieldMapper.GetObjetMapped <List <FlightDto> >(response, metadataCofig.Response);

            if (fly != null)
            {
                trips.Add(new TripDto {
                    Flights = fly
                });
            }

            return(trips);
        }