public async Task <ComplejoDeportivo> InsertarAsync(ComplejoDeportivo param) { using (SqlConnection conexion = _conexionDb.ObtenerConexionDb()) { using (SqlCommand consulta = new SqlCommand("spInsertarComplejo", conexion)) { consulta.CommandType = CommandType.StoredProcedure; consulta.Parameters.Add(new SqlParameter("@SedeId", param.SedeId)); consulta.Parameters.Add(new SqlParameter("@TipoComplejoId", param.TipoComplejoId)); consulta.Parameters.Add(new SqlParameter("@JefeId", param.JefeId)); consulta.Parameters.Add(new SqlParameter("@Complejo", param.Complejo)); consulta.Parameters.Add(new SqlParameter("@Localizacion", param.Localizacion)); consulta.Parameters.Add(new SqlParameter("@NoArea", param.NoArea)); consulta.Parameters.Add(new SqlParameter("@Estado", param.Estado)); consulta.Parameters.Add(new SqlParameter("@ComplejoId", SqlDbType.Int)).Direction = ParameterDirection.Output; await conexion.OpenAsync(); await consulta.ExecuteNonQueryAsync(); param.ComplejoId = int.Parse(consulta.Parameters["@ComplejoId"].Value.ToString()); } } return(param); }
protected void btn_Agregar_Click(object sender, EventArgs e) { Mapa m = new Mapa(); if (string.IsNullOrEmpty(txt_Latitud.Text) || string.IsNullOrEmpty(txt_Longitud.Text)) { m.latitud = "-31.416563"; m.longitud = "-64.183533"; } else { m.latitud = txt_Latitud.Text; m.longitud = txt_Longitud.Text; } int idMapa = MapaDao.insertarMapa(m); ComplejoDeportivo cd = new ComplejoDeportivo(); cd.id = int.Parse(Session["IDCom"].ToString()); cd.mapa = idMapa; ComplejoDeportivoDao.ActualizarMapaComplejo(cd); limpiarCampos(); cargarMapa(int.Parse(Session["IDCom"].ToString())); }
public async Task <bool> ActualizarAsync(int complejoId, ComplejoDeportivo param) { if (!param.EsValido()) { _logger.LogError("Problema para actualizar el complejo."); return(false); } return(await _repositorio.ActualizarAsync(complejoId, param)); }
public async Task <ComplejoDeportivo> InsertarAsync(ComplejoDeportivo param) { if (!param.EsValido()) { _logger.LogError("Problema para registrar el complejo."); return(param); } return(await _repositorio.InsertarAsync(param)); }
protected void btn_Eliminar_Click(object sender, EventArgs e) { MapaDao.eliminarMapa(int.Parse(Session["idMapa"].ToString())); ComplejoDeportivo cd = new ComplejoDeportivo(); cd.id = int.Parse(Session["idComplejo"].ToString()); cd.mapa = null; ComplejoDeportivoDao.ActualizarMapaComplejo(cd); limpiarCampos(); cargarGrilla(); }
protected void btnGuardarCan_Click(object sender, EventArgs e) { if (ddlDep4.SelectedValue != "0" && (ddlTipoCancha.SelectedValue != "0" && ddlTipoCancha.SelectedValue != "")) { Cancha cancha = new Cancha(); cancha.nombre = txtNomCan.Text; cancha.descripcion = txtDesCan.Text; int tipoCan; if (int.TryParse(ddlTipoCancha.Text, out tipoCan)) { cancha.idTipoCancha = tipoCan; } cancha.idComplejo = IDCom.Value; if (IDCan.HasValue) { cancha.id = IDCan.Value; CanchaDao.ActualizarCancha(cancha); } else { CanchaDao.InsertarCancha(cancha); } if (ComplejoDeportivoDao.ExisteDeporte(IDCom.Value, ddlDep4.SelectedItem.ToString()) == false) { ComplejoDeportivo complejo = new ComplejoDeportivo(); complejo.id = IDCom.Value; complejo.deportes = ddlDep4.SelectedItem.ToString(); ComplejoDeportivoDao.ActualizarDeportesComplejo(complejo); } CargarGrillaCanchas(); LimpiarCanchas(); } }
public async Task <ActionResult <bool> > Put(int id, [FromBody] ComplejoDeportivo param) { bool response = false; try { response = await _negocio.ActualizarAsync(id, param); } catch (Exception exc) { _logger.LogCritical(exc.Message); return(StatusCode( StatusCodes.Status500InternalServerError, new { status = StatusCodes.Status500InternalServerError, title = "Error interno del servidor, algo salió mal!!!" })); } return(Ok(response)); }
public async Task <ActionResult <ComplejoDeportivo> > Post([FromBody] ComplejoDeportivo param) { ComplejoDeportivo response = null; try { response = await _negocio.InsertarAsync(param); } catch (Exception exc) { _logger.LogCritical(exc.Message); return(StatusCode( StatusCodes.Status500InternalServerError, new { status = StatusCodes.Status500InternalServerError, title = "Error interno del servidor, algo salió mal!!!" })); } return(Ok(response)); }
// MAPA private void cargarMapa(int idComplejoDeportivo) { ComplejoDeportivo cd = ComplejoDeportivoDao.ObtenerComplejosPorID(idComplejoDeportivo); //int? id = cd.mapa.Value; if (!string.IsNullOrEmpty(cd.mapa.ToString())) { // int idMapa = int.Parse(id.ToString()); int idMapa = int.Parse(cd.mapa.Value.ToString()); Mapa mapa = MapaDao.obtenerMapaByID(idMapa); txt_Latitud.Text = mapa.latitud; txt_Longitud.Text = mapa.longitud; btn_Agregar.Enabled = false; btn_Modificar.Enabled = true; btn_Eliminar.Enabled = true; } else { btn_Agregar.Enabled = true; btn_Modificar.Enabled = false; btn_Eliminar.Enabled = false; } }
protected void btn_Agregar_Click(object sender, EventArgs e) { Mapa m = new Mapa(); ComplejoDeportivo cd = new ComplejoDeportivo(); // ** NO BORRAR ** //double lat; //double lng; //if(double.TryParse(txt_Latitud.Text,out lat)) // m.latitud = lat; //if (double.TryParse(txt_Longitud.Text, out lng)) // m.longitud = lng; //m.latitud = txt_Latitud.Text; //m.longitud = txt_Longitud.Text; m.latitud = txt_Latitud.Value; m.longitud = txt_Longitud.Value; int idMapa = MapaDao.insertarMapa(m); // cd.id = cmb_Complejo.SelectedIndex; // string comp = cmb_Complejo.SelectedItem.Text; int cmbID = 0; if (int.TryParse(cmb_Complejo.SelectedItem.Value, out cmbID)) { cd.id = cmbID; } cd.mapa = idMapa; ComplejoDeportivoDao.ActualizarMapaComplejo(cd); limpiarCampos(); cargarGrilla(); }
protected void btnGuardar_Click(object sender, EventArgs e) { ComplejoDeportivo complejo = new ComplejoDeportivo(); complejo.nombre = txtNomb.Text; complejo.descripcion = txtDesc.Text; complejo.deportes = lblDepResultado.Text; complejo.responsable = txtNomRes.Text + " " + txtApeRes.Text; complejo.idUsuario = int.Parse(Session["ID"].ToString()); complejo.promedioEstrellas = 0; complejo.idEstado = 1; complejo.calle = txtCalle.Text; int nroCalle; if (int.TryParse(txtNro.Text, out nroCalle)) { complejo.nroCalle = nroCalle; } if (ddlBarrio.Text != "0") { int barrio; if (int.TryParse(ddlBarrio.Text, out barrio)) { complejo.idBarrio = barrio; } } else { complejo.idBarrio = null; } long tel; if (long.TryParse(txtTel.Text, out tel)) { complejo.nroTelefono = tel; } TimeSpan horaApe; if (TimeSpan.TryParse(txtHoraApe.Text, out horaApe)) { complejo.horaApertura = horaApe; } TimeSpan horaCie; if (TimeSpan.TryParse(txtHoraCie.Text, out horaCie)) { complejo.horaCierre = horaCie; } //Guardar Avatar if (FileUploadAvatar.HasFile) { //obtener datos de la imagen int tam = FileUploadAvatar.PostedFile.ContentLength; byte[] ImagenOriginal = new byte[tam]; FileUploadAvatar.PostedFile.InputStream.Read(ImagenOriginal, 0, tam); Bitmap ImagenOriginalBinaria = new Bitmap(FileUploadAvatar.PostedFile.InputStream); //insertar en BD complejo.avatar = ImagenOriginal; //string ImagenDataURL64 = "data:image/jpg;base64," + Convert.ToBase64String(ImagenOriginal); //Image1.ImageUrl = ImagenDataURL64; //imgAvatar.ImageUrl = "~/AvatarComplejo.aspx?id=" + Session["ID"].ToString(); FileUploadAvatar.Visible = false; btn_guardarImagen.Visible = false; btn_CambiarImagen.Visible = true; } else { //obtener datos de la imagen byte[] ImagenOriginal; string someUrl = @"C:\Users\linov\Documents\GitHub\desarrollo\HayEquipo\CapaPresentacion\Imagenes\complejo_logo_default.png"; using (var webClient = new WebClient()) { ImagenOriginal = webClient.DownloadData(someUrl); } //insertar en BD complejo.avatar = ImagenOriginal; FileUploadAvatar.Visible = false; btn_guardarImagen.Visible = false; btn_CambiarImagen.Visible = true; } if (IDCom.HasValue) { complejo.id = IDCom.Value; ComplejoDeportivoDao.ActualizarComplejo(complejo); } else { complejo.fechaRegistro = DateTime.Today; ComplejoDeportivoDao.InsertarComplejo(complejo); } CargarComplejo(); }