protected void Page_Load(object sender, EventArgs e) { var idCochera = int.Parse(HttpContext.Current.Request.QueryString.Get("idcochera")); Cochera = _cocherasServicio.ObtenerCocheraPorId(Math.Abs(idCochera)); hdPrecioHora.Value = Cochera.Precio.ToString(); }
public void Guardar(Cocheras cochera) { try { _db.Cocheras.Add(cochera); _db.SaveChanges(); } catch (Exception e) { throw new Exception("Error: no se ha podido guardar la cochera"); } }
protected void btnCrearCochera_Click(object sender, EventArgs e) { if (Page.IsValid) { try { var cochera = new Cocheras { IdPropietario = _propietario.IdUsuario, Ubicacion = txtUbicacion.Text, Latitud = Convert.ToDecimal(txtLatitud.Text), Longitud = Convert.ToDecimal(txtLongitud.Text), MetrosCuadrados = int.Parse(txtMetrosCuadrados.Text), Descripcion = txtDescripcion.Text, Precio = Convert.ToDecimal(txtPrecioHora.Text), FechaInicio = txtFechaInicio.Text.ToDateTime(txtHorarioInicio.Text), FechaFin = txtFechaFin.Text.ToDateTime(txtHorarioFin.Text), Imagen = fuFoto.Text, HoraInicio = txtHorarioInicio.Text, HoraFin = txtHorarioFin.Text }; var cantidadTipoVehiculoSeleccionados = lbTipoVehiculo.GetSelectedIndices(); if (cantidadTipoVehiculoSeleccionados.Length > 1) { foreach (var tipoVehiculo in cantidadTipoVehiculoSeleccionados) { // guardar la cochera modificando la Descripción } } else { // guardar normalmente } _cocherasServicio.Guardar(cochera); lblResultado.Text = "Operación Exitosa"; } catch (Exception ex) { lblResultado.Text = ex.Message; } } else { lblResultado.Text = "Algo salió mal..."; } }
public void Guardar(Cocheras cochera) { _cocherasRepositorio.Guardar(cochera); }