public int crearBajaTemporal(CierreTemporal cierreTemporal) { RepositorioCierreTemporal repositorioCierreTemporal = new RepositorioCierreTemporal(); RepositorioReserva repositorioReserva = new RepositorioReserva(); Hotel hotel = cierreTemporal.getHotel(); bool existReservas = repositorioReserva.existReservaBetweenDate(cierreTemporal.getFechaInicio(), cierreTemporal.getFechaFin(), cierreTemporal.getHotel().getIdHotel()); if (existReservas) { throw new RequestInvalidoException("No es posible dar de baja temporal el hotel. Existen reservas para la fecha la cual se quiere dar de baja el hotel"); } return(repositorioCierreTemporal.create(cierreTemporal)); }
private void bajaHotel_Click(object sender, EventArgs e) { DateTime fechaDesde = calendarioDesde.Value; DateTime fechaHasta = calendarioHasta.Value; if (fechaDesde < Utils.getSystemDatetimeNow()) { MessageBox.Show("No puede realizar reservas en el pasado", "Error"); return; } if (fechaDesde > fechaHasta) { MessageBox.Show("La fecha inicio no puede ser superior a la fecha final.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (descripcionBajaText.Text.Equals("")) { MessageBox.Show("Debe ingresar una descripción válida para el cierre temporal.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { CierreTemporal cierreTemporal = new CierreTemporal(0, fechaDesde, fechaHasta, descripcionBajaText.Text, hotelBaja); RepositorioHotel repoHotel = new RepositorioHotel(); repoHotel.crearBajaTemporal(cierreTemporal); MessageBox.Show("Cierre temporal creado exitosamente.", "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Information); this.buttonLimpiarDatos_Click(sender, e); } //catch (RequestInvalidoException exception) catch (Exception exception) { MessageBox.Show(exception.Message, "Gestion de Datos TP 2018 1C - LOS_BORBOTONES", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }