private void dgvDatos_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgvDatos.RowCount > 0 && dgvDatos.SelectedRows.Count > 0) { if (dgvDatos.CurrentCell.Selected) { FHabitacion = dgvDatos.SelectedRows[0].DataBoundItem as HabitacionDTO; this.DialogResult = DialogResult.OK; } } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); MessageBox.Show(msg.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <IActionResult> Modificar(int id, [FromBody] HabitacionDTO dto) { var habitacion = HabitacionMapper.Map(dto); await _habitacionService.ModificarAsync(id, habitacion); return(Ok()); }
public async Task <HttpResponseMessage> CrearUnaHabitacionPrivada() { var body = new HabitacionDTO { Nombre = "Azul", EsPrivada = true, TieneBanio = true, InformacionAdicional = "asd", CamasIndividuales = new List <CamaDTO> { new CamaDTO { Nombre = "Indi" } }, CamasMatrimoniales = new List <CamaDTO> { new CamaDTO { Nombre = "Ma" } }, CamasCuchetas = new List <CamaCuchetaDTO> { new CamaCuchetaDTO { Nombre = "Cucheta" } } }; return(await _httpClient.PostAsJsonAsync(ENDPOINT, body)); }
public static Habitacion Map(HabitacionDTO dto) { if (dto.EsPrivada) { return new HabitacionPrivada { Nombre = dto.Nombre, TieneBanio = dto.TieneBanio, InformacionAdicional = dto.InformacionAdicional, CamasIndividuales = dto.CamasIndividuales?.ConvertAll(camaIndividual => new CamaIndividual { Nombre = camaIndividual.Nombre }), CamasMatrimoniales = dto.CamasMatrimoniales?.ConvertAll(camaMatrimonial => new CamaMatrimonial { Nombre = camaMatrimonial.Nombre }), CamasCuchetas = dto.CamasCuchetas?.ConvertAll(dtoCamasCucheta => new CamaCucheta { Abajo = new CamaCuchetaDeAbajo { Nombre = dtoCamasCucheta.Nombre }, Arriba = new CamaCuchetaDeArriba { Nombre = dtoCamasCucheta.Nombre } }), } } ; else { return new HabitacionCompartida { Nombre = dto.Nombre, TieneBanio = dto.TieneBanio, InformacionAdicional = dto.InformacionAdicional, CamasIndividuales = dto.CamasIndividuales?.ConvertAll(camaIndividual => new CamaIndividual { Nombre = camaIndividual.Nombre }), CamasMatrimoniales = dto.CamasMatrimoniales?.ConvertAll(camaMatrimonial => new CamaMatrimonial { Nombre = camaMatrimonial.Nombre }), CamasCuchetas = dto.CamasCuchetas?.ConvertAll(dtoCamasCucheta => new CamaCucheta { Abajo = new CamaCuchetaDeAbajo { Nombre = dtoCamasCucheta.Nombre }, Arriba = new CamaCuchetaDeArriba { Nombre = dtoCamasCucheta.Nombre } }), } }; }
private void btnBuscarProducto_Click(object sender, EventArgs e) { frmFiltroHabi ofrmFiltroHabi = new frmFiltroHabi(); HabitacionDTO oHabitacion = null; try { ofrmFiltroHabi.ShowDialog(); if (ofrmFiltroHabi.DialogResult == DialogResult.OK) { oHabitacion = ofrmFiltroHabi.FHabitacion; this.mskNUMHabitacion.Text = oHabitacion.NUM.ToString(); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public List <HabitacionDTO> GetAllHabitacion() { DataSet ds = null; List <HabitacionDTO> lista = new List <HabitacionDTO>(); SqlCommand command = new SqlCommand(); string sql = @"usp_SELECT_Habitacion_All"; try { command.CommandText = sql; command.CommandType = CommandType.StoredProcedure; using (IDataBase db = FactoryDataBase.CreateDataBase(FactoryConexion.CreateConnection(_Usuario.Login, _Usuario.Password))) { ds = db.ExecuteReader(command, "query"); } // Si devolvió filas if (ds.Tables[0].Rows.Count > 0) { // Iterar en todas las filas y Mapearlas foreach (DataRow dr in ds.Tables[0].Rows) { HabitacionDTO oHabitacionDTO = new HabitacionDTO() { NUM = double.Parse(dr["NUM"].ToString()), Descripcion = dr["Descripcion"].ToString(), Foto = (byte[])dr["Foto"], Estado = (int)dr["Estado"], Precio = double.Parse(dr["Precio"].ToString()) }; lista.Add(oHabitacionDTO); } } return(lista); } catch (SqlException sqlError) { StringBuilder msg = new StringBuilder(); msg.AppendFormat(Utilitarios.CreateSQLExceptionsErrorDetails(sqlError)); msg.AppendFormat("SQL {0}\n", command.CommandText); //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); throw; } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat(Utilitarios.CreateGenericErrorExceptionDetail(er)); //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); throw; } }
public void NavegarHabitacionCommandExecute() { if (itemUsuario.Habitaciones_oid != null && itemUsuario.Habitaciones_oid.Count() > 0) { HabitacionDTO habitacion = service.NuevoInmueblate_Habitacion_DameHabitacionPorOID(itemUsuario.Habitaciones_oid[0]); NavigationViewModel.Instance.Back.Push(NavigationViewModel.Instance.CurrentPage); NavigationViewModel.Instance.CurrentPage = new views.Habitacion.HabitacionDetalle(); NavigationViewModel.Instance.CurrentPage.DataContext = new HabitacionDetalleViewModel(habitacion, "> Detalles de la habitación con Id " + habitacion.Id + " "); } }
public static HabitacionEN Convert(HabitacionDTO dto) { HabitacionEN newinstance = null; try { if (dto != null) { newinstance = new HabitacionEN(); newinstance.Id = dto.Id; newinstance.PendienteModeracion = dto.PendienteModeracion; newinstance.Descripcion = dto.Descripcion; newinstance.MetrosCuadrados = dto.MetrosCuadrados; newinstance.Alquiler = dto.Alquiler; if (dto.Inquilinos_oid != null) { NuevoInmueblateGenNHibernate.CAD.RedSocial.IUsuarioCAD usuarioCAD = new NuevoInmueblateGenNHibernate.CAD.RedSocial.UsuarioCAD(); newinstance.Inquilinos = new System.Collections.Generic.List <NuevoInmueblateGenNHibernate.EN.RedSocial.UsuarioEN>(); foreach (int entry in dto.Inquilinos_oid) { newinstance.Inquilinos.Add(usuarioCAD.ReadOIDDefault(entry)); } } if (dto.Caracteristicas_oid != null) { NuevoInmueblateGenNHibernate.CAD.RedSocial.ICaracteristicaCAD caracteristicaCAD = new NuevoInmueblateGenNHibernate.CAD.RedSocial.CaracteristicaCAD(); newinstance.Caracteristicas = new System.Collections.Generic.List <NuevoInmueblateGenNHibernate.EN.RedSocial.CaracteristicaEN>(); foreach (int entry in dto.Caracteristicas_oid) { newinstance.Caracteristicas.Add(caracteristicaCAD.ReadOIDDefault(entry)); } } if (dto.Inmueble_oid != -1) { NuevoInmueblateGenNHibernate.CAD.RedSocial.IInmuebleCAD inmuebleCAD = new NuevoInmueblateGenNHibernate.CAD.RedSocial.InmuebleCAD(); newinstance.Inmueble = inmuebleCAD.ReadOIDDefault(dto.Inmueble_oid); } } } catch (Exception ex) { throw ex; } return(newinstance); }
private void toolStripBtnEditar_Click(object sender, EventArgs e) { HabitacionDTO oHabitacionDTO = null; try { if (this.dgvDatos.SelectedRows.Count > 0) { // Cambiar de estado this.CambiarEstado(EstadoMantenimiento.Editar); //Extraer el DTO seleccionado oHabitacionDTO = this.dgvDatos.SelectedRows[0].DataBoundItem as HabitacionDTO; this.mskCodigo.Text = oHabitacionDTO.NUM.ToString(); this.mskDescripcion.Text = oHabitacionDTO.Descripcion; this.pbImagen.BackgroundImage = null; this.pbImagen.Image = new Bitmap(new MemoryStream(oHabitacionDTO.Foto)); this.pbImagen.SizeMode = PictureBoxSizeMode.StretchImage; this.pbImagen.Tag = oHabitacionDTO.Foto; this.txtPrecio.Text = oHabitacionDTO.Precio.ToString(); if (oHabitacionDTO.Estado == 1) { this.chkDisponible.Checked = true; } else { this.chkOcupado.Checked = true; } } else { MessageBox.Show("Seleccione el registro !", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error // _MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task Error400_PorBodyIncorrectoEnPost() { var bodySinUnCampoRequerido = new HabitacionDTO { CamasIndividuales = new List <CamaDTO>(), CamasMatrimoniales = new List <CamaDTO>(), CamasCuchetas = new List <CamaCuchetaDTO>() }; var response = await _httpClient.PostAsJsonAsync(ENDPOINT, bodySinUnCampoRequerido); response.StatusCode.Should().Be(HttpStatusCode.BadRequest); var responseContent = await response.Content.ReadAsStringAsync(); responseContent.Should().Contain("Nombre"); }
public HabitacionDetalleViewModel(HabitacionDTO habitacion, string breadcrumb) { service = new ServiceClient(); itemHabitacion = habitacion; NavigationViewModel.Instance.Cabecera = "Detalle de la habitación"; NavigationViewModel.Instance.Breadcrumbs += breadcrumb; inmueble = service.NuevoInmueblate_Inmueble_DameInmueblePorOID(habitacion.Inmueble_oid); geolocalizacion = service.NuevoInmueblate_Geolocalizacion_DameGeolocalizacionPorOID(inmueble.Geolocalizacion_oid); foreach (int i in habitacion.Caracteristicas_oid) { listaCaracteristicas.Add(service.NuevoInmueblate_Caracteristica_DameCaracteristicaPorOID(i)); } }
private void DadoUnHabitacionDto() { _unaHabitacionDTO = new HabitacionDTO { Nombre = "Azul", EsPrivada = true, TieneBanio = true, InformacionAdicional = "asd", CamasIndividuales = new List <CamaDTO> { new CamaDTO { Nombre = "Indi" } }, CamasCuchetas = new List <CamaCuchetaDTO> { new CamaCuchetaDTO { Abajo = new CamaDTO { Nombre = "Abajo" }, Arriba = new CamaDTO { Nombre = "Arriba" } } }, CamasMatrimoniales = new List <CamaDTO> { new CamaDTO { Nombre = "Matri" } } }; }
public static HabitacionDTO Convert(HabitacionEN en) { HabitacionDTO newinstance = null; if (en != null) { newinstance = new HabitacionDTO(); newinstance.Id = en.Id; newinstance.PendienteModeracion = en.PendienteModeracion; newinstance.Descripcion = en.Descripcion; newinstance.MetrosCuadrados = en.MetrosCuadrados; newinstance.Alquiler = en.Alquiler; if (en.Inquilinos != null) { newinstance.Inquilinos_oid = new System.Collections.Generic.List <int>(); foreach (NuevoInmueblateGenNHibernate.EN.RedSocial.UsuarioEN entry in en.Inquilinos) { newinstance.Inquilinos_oid.Add(entry.Id); } } if (en.Caracteristicas != null) { newinstance.Caracteristicas_oid = new System.Collections.Generic.List <int>(); foreach (NuevoInmueblateGenNHibernate.EN.RedSocial.CaracteristicaEN entry in en.Caracteristicas) { newinstance.Caracteristicas_oid.Add(entry.Id); } } if (en.Inmueble != null) { newinstance.Inmueble_oid = en.Inmueble.Id; } } return(newinstance); }
private async Task <int> CrearHabitacionConUnaCama() { var body = new HabitacionDTO { Nombre = "Roja", EsPrivada = false, CamasIndividuales = new List <CamaDTO> { new CamaDTO { Nombre = "Indios", Tipo = CAMA_TIPO } } }; await _httpClient.PostAsJsonAsync(ENDPOINT_HABITACIONES, body); var habitacionesDTO = await(await _httpClient.GetAsync(ENDPOINT_HABITACIONES)).Content .ReadAsAsync <IEnumerable <HabitacionDTO> >(); return(habitacionesDTO.First().CamasIndividuales.First().Id); }
private void toolStripBtnBorrar_Click(object sender, EventArgs e) { IBLLHabitacion _BLLHabitacion = new BLLHabitacion(); try { if (this.dgvDatos.SelectedRows.Count > 0) { this.CambiarEstado(EstadoMantenimiento.Borrar); HabitacionDTO oHabitacionDTO = this.dgvDatos.SelectedRows[0].DataBoundItem as HabitacionDTO; if (MessageBox.Show($"¿Seguro que desea borrar el registro {oHabitacionDTO.NUM} {oHabitacionDTO.Descripcion}?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { _BLLHabitacion.DeleteHabitacion(oHabitacionDTO.NUM); this.CargarDatos(); } } else { MessageBox.Show("Seleccione el registro !", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception er) { StringBuilder msg = new StringBuilder(); msg.AppendFormat("Message {0}\n", er.Message); msg.AppendFormat("Source {0}\n", er.Source); msg.AppendFormat("InnerException {0}\n", er.InnerException); msg.AppendFormat("StackTrace {0}\n", er.StackTrace); msg.AppendFormat("TargetSite {0}\n", er.TargetSite); // Log error //_MyLogControlEventos.ErrorFormat("Error {0}", msg.ToString()); // Mensaje de Error MessageBox.Show("Se ha producido el siguiente error " + er.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public async Task <int> Crear([FromBody] HabitacionDTO dto) { var habitacion = HabitacionMapper.Map(dto); return(await _habitacionService.CrearAsync(habitacion)); }