public async Task <IActionResult> Modificar(int id, [FromBody] HabitacionDTO dto) { var habitacion = HabitacionMapper.Map(dto); await _habitacionService.ModificarAsync(id, habitacion); return(Ok()); }
private static void LlenarListas() { listaHabitaciones = new List <Habitacion>(); foreach (Hotel h in listaHoteles) { listaHabitaciones.AddRange(HabitacionMapper.TraerHabitacionesPorId(h.Id)); } }
private static void RefrescarCache() { cacheReservas = ReservaMapper.TraerReservas(); listaHoteles = HotelMapper.TraerHoteles(); listaClientes = ClienteServicio.TraerClientes(); listaHoteles.ForEach(x => x.Habitaciones.AddRange(HabitacionMapper.TraerHabitacionesPorId(x.Id))); LlenarListas(); }
private void HabitacionesCache() { _listaHabitaciones.Clear(); foreach (Hotel a in _listahoteles) { _listaHabitaciones.AddRange(HabitacionMapper.Habitacion_getAllByHotel(a.Id)); } }
public static void InsertarHabitacion(Habitacion habitacion) { TransactionResult result = HabitacionMapper.Insert(habitacion); if (!result.IsOk) { throw new ErrorServidorException(result.Error); } }
public HotelServicios() { _listahoteles = new List <Hotel>(); _listaHabitaciones = new List <Habitacion>(); _listaReservas = new List <Reserva>(); //Cache _listaclientes = ClienteMapper.TraerTodos(); _listahoteles = HotelMapper.Hotel_getAll(); _listaReservas = ReservaMapper.Reserva_getAll(); foreach (Hotel a in _listahoteles) { _listaHabitaciones.AddRange(HabitacionMapper.Habitacion_getAllByHotel(a.Id)); } }
public void MapeaCorrectamenteEnLaCreacion() { DadoUnHabitacionDto(); var habitacion = HabitacionMapper.Map(_unaHabitacionDTO); habitacion.CamasMatrimoniales.Count.Should().Be(1); habitacion.CamasIndividuales.Count.Should().Be(1); habitacion.CamasCuchetas.Count.Should().Be(1); habitacion.TieneBanio.Should().BeTrue(); habitacion.InformacionAdicional.Should().Be("asd"); habitacion.Tipo().Should().Be(HabitacionTipoEnum.Privada); }
public void MapeaCorrectamenteEnLaConsulta() { DadaUnaListaDeHabitaciones(); var habitacionesDTO = HabitacionMapper.Map(_unaListaDeHabitaciones); habitacionesDTO.First().EsPrivada.Should().BeTrue(); habitacionesDTO.First().TieneBanio.Should().BeTrue(); habitacionesDTO.First().InformacionAdicional.Should().Be("asd"); habitacionesDTO.First().EsPrivada.Should().Be(true); habitacionesDTO.First().CamasMatrimoniales.Count.Should().Be(1); habitacionesDTO.First().CamasIndividuales.Count.Should().Be(1); habitacionesDTO.First().CamasCuchetas.Count.Should().Be(1); }
public int EliminarHabitacion(int id) { if (_listaReservas.Any(o => o.IdHabitacion == id)) { throw new ReservasException("Habitacion con reservas. Debe eliminarlas."); } TransactionResult resultado = HabitacionMapper.Delete(id); if (resultado.IsOk) { HabitacionesCache(); return(resultado.Id); } else { throw new ReservasException(resultado.Error); } }
public int ModificarHabitacion(Habitacion habitacion) { var minimo = int.Parse(ConfigurationSettings.AppSettings["PrecioMinimo"]); if (habitacion.Precio <= minimo) { throw new ReservasException("El precio debe ser superior a " + minimo.ToString()); } if (habitacion.CantidadPlazas <= 0) { throw new ReservasException("La cantidad de plaza debe ser mayor que 0"); } TransactionResult resultado = HabitacionMapper.Update(habitacion); if (resultado.IsOk) { HabitacionesCache(); return(resultado.Id); } else { throw new ReservasException(resultado.Error); } }
public async Task <int> Crear([FromBody] HabitacionDTO dto) { var habitacion = HabitacionMapper.Map(dto); return(await _habitacionService.CrearAsync(habitacion)); }
public async Task <IEnumerable <HabitacionConLugaresLibresDTO> > ListarConLugaresLibres(DateTime desde, DateTime hasta) { var habitaciones = await _habitacionService.ListarConLugaresLibresEntre(desde, hasta); return(HabitacionMapper.MapHabitacionesConLugaresLugares(habitaciones)); }
public async Task <HabitacionDetalleDTO> ObtenerPorId(int id) { var habitacion = await _habitacionService.ObtenerPorId(id); return(HabitacionMapper.MapDetalle(habitacion)); }
public async Task <IEnumerable <HabitacionDTO> > Listar() { var habitaciones = await _habitacionService.ListarAsync(); return(HabitacionMapper.Map(habitaciones)); }
public static List <Habitacion> TraerHabitacionesPorId(int idHotel) { return(HabitacionMapper.TraerHabitacionesPorId(idHotel)); }