public UnitListModel PrepareUnitListModel(UnitSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get items var items = _unitService.GetAllUnits(); //prepare list model var model = new UnitListModel { //fill in model values from the entity Data = items.PaginationByRequestModel(searchModel).Select(store => store.ToModel <UnitModel>()), Total = items.Count }; return(model); }
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); }