Пример #1
0
            public LodgingModel SearchLodgingInfo(SearchLodgingRequestModel searchLodgingRequestModel, Credential userCredential)
            {
                SessionData.SearchType = SearchType.National;

                LodgingModel result = new LodgingModel();

                if (searchLodgingRequestModel.Checkin == null)
                {
                    searchLodgingRequestModel.Checkin = DateTime.Now.Date;
                }
                if (searchLodgingRequestModel.Checkout == null)
                {
                    searchLodgingRequestModel.Checkout = DateTime.Now.Date;
                }
                var petition = new PeticionInfoAlojamiento();

                petition.IdAlojamiento = Guid.Parse(searchLodgingRequestModel.LodgingId);
                CompletePetition(petition, userCredential);

                var petitionResults = _service.InfoAlojamiento(petition);

                if (petitionResults.Estado == EstadoRespuesta.Ok)
                {
                    var lodging = petitionResults.Alojamiento;

                    var lodgingModel = new LodgingModel
                    {
                        LodgingId                 = lodging.IdAlojamiento.ToString(),
                        LodgingName               = lodging.Nombre,
                        LodgingDescription        = lodging.Descripcion,
                        LodgingCategory           = GetCategory(lodging.Categoria),
                        LodgingPhoto              = lodging.FotoAlojamientoUrl,
                        LodgingCity               = lodging.Destino.NombreDestino,
                        LodgingCancelationPolitic = lodging.PoliticasCancelacion,
                        LodgingLocation           = lodging.Direccion,
                        LodgingServices           = lodging.Amenidades,
                        LodgingPhone              = lodging.Telefono,
                        Latitud  = lodging.Latitud,
                        Longitud = lodging.Longitud
                                   //LodgingPrice = CalculateTotalPrice(lodging, petition.Habitacion1 ?? 0, petition.Habitacion2 ?? 0,
                                   //        petition.Habitacion3 ?? 0, petition.Habitacion4 ?? 0, 0, 0)
                    };

                    var currency = "$";

                    switch (lodging.Moneda)
                    {
                    case Moneda.ARS: currency = "$"; break;

                    case Moneda.EUR: currency = "€"; break;

                    case Moneda.USD: currency = "U$S"; break;
                    }

                    lodgingModel.LodgingCurrency     = currency;
                    lodgingModel.LodgingCurrencyCode = MapCurrencyToNPS(lodging.Moneda);

                    var vacancies = new List <VacancyModel>();

                    if (lodging.Unidades != null)
                    {
                        var vacancyGroups = lodging.Unidades.GroupBy(u => u.IdUnidad);

                        foreach (var group in vacancyGroups)
                        {
                            var vacancy = group.Select(v => new VacancyModel
                            {
                                LodgingId       = lodgingModel.LodgingId,
                                LodgingName     = lodgingModel.LodgingName,
                                LodgingCurrency = lodgingModel.LodgingCurrency,
                                VacancySelected = false,
                                VacancyId       = v.IdUnidad.ToString(),
                                VacancyName     = v.NombreUnidad,
                                VacancyAdults   = v.Personas,
                                VacancyBeds     = v.Camas,
                                VacancyCount    = v.Disponibles,
                                //VacancyPrice = v.MontoPorUnidad,
                                VacancyCheckin        = searchLodgingRequestModel.Checkin,
                                VacancyCheckout       = searchLodgingRequestModel.Checkout,
                                VacancyDates          = group.Select(vg => vg.Fecha).ToList(),
                                Available             = true,
                                ConfirmedVacancyPrice = v.MontoPorUnidadRaCdTr,

                                Rooms = new List <RoomModel> {
                                    new RoomModel {
                                        RoomId     = v.IdUnidad.ToString(),
                                        RoomName   = v.NombreUnidad,
                                        RoomAdults = v.Personas,
                                        RoomBeds   = v.Camas,
                                        RoomCount  = v.Disponibles,
                                    }
                                }
                            }).First();

                            vacancies.Add(vacancy);
                        }
                        lodgingModel.Vacancies = vacancies;
                    }
                    result = lodgingModel;
                }

                return(result);
            }
Пример #2
0
        public UnitListModel GetLodgingWeeklyPrices(Guid lodgingId, DateTime date, Credential userCredential, string nationality)
        {
            SessionData.SearchType = SearchType.National;
            UnitListModel result   = new UnitListModel();
            var           petition = new PeticionInfoAlojamiento()
            {
                IdAlojamiento = lodgingId,
                Fecha         = date,
                Nationality   = nationality
            };

            CompletePetition(petition, userCredential);
            var petitionResults = _service.BuscarPreciosSemanalesHotel(petition);

            if (petitionResults.Estado == EstadoRespuesta.Ok)
            {
                var currency = "$";

                switch (petitionResults.Alojamiento.Unidades.FirstOrDefault().Moneda.GetValueOrDefault())
                {
                case Moneda.ARS: currency = "$"; break;

                case Moneda.EUR: currency = "€"; break;

                case Moneda.USD: currency = "U$S"; break;
                }

                result.Units = petitionResults.Alojamiento.Unidades.Select(uni => new Unit()
                {
                    IdUnidad     = uni.IdUnidad,
                    NombreUnidad = uni.NombreUnidad,
                    Personas     = uni.Personas,
                    Description  = uni.Descripcion,
                    Moneda       = currency,
                    Quota        = uni.Cupos.Select(quota => new Quota()
                    {
                        Activo               = quota.Activo,
                        BloqueadoPorPromo    = quota.BloaqueadoPorPromo,
                        CupoMaximo           = quota.Cupomaximo,
                        CupoReservado        = quota.CupoReservado,
                        Fecha                = quota.Fecha,
                        Fecha_Alta           = quota.Fecha_Alta,
                        IdCupoUnidad         = quota.IdCupoUnidad,
                        IdUnidadAloj         = quota.IdUnidadAloj,
                        MarcaTemporada       = quota.MarcaTemporada,
                        Monto                = quota.Monto,
                        MontoExtranjero      = quota.MontoExtranjero,
                        MontoMercosur        = quota.MontoMercosur,
                        MontoExtranjeroCDTR  = quota.MontoExtranjeroCDTR,
                        MontoMercosurCDTR    = quota.MontoMercosurCDTR,
                        MontoArgentinoSDTR   = quota.MontoArgentinoSDTR,
                        MontoExtranjeroSDTR  = quota.MontoExtranjeroSDTR,
                        MontoMercosurSDTR    = quota.MontoMercosurSDTR,
                        MontoArgentinoCDTNR  = quota.MontoArgentinoCDTNR,
                        MontoExtrajeroCDTNR  = quota.MontoExtrajeroCDTNR,
                        MontoMercosurCDTNR   = quota.MontoMercosurCDTNR,
                        MontoArgentinoSDTNR  = quota.MontoArgentinoSDTNR,
                        MontoExtranjeroSDTNR = quota.MontoExtranjeroSDTNR,
                        MontoMercosurSDTNR   = quota.MontoMercosurCDTNR,
                    }).ToArray()
                }).ToArray();
            }
            return(result);
        }