Example #1
0
        public void Editar(AnuncioModelo modelo)
        {
            var consulta = "UPDATE Anuncio SET DuracionAnuncio = @DuracionAnuncio, PrecioPorSegundo = @PrecioPorSegundo WHERE IdAnuncio =@IdAnuncio";

            using (var con = new SqlConnection(connectionString))
            {
                con.Execute(consulta, new { modelo.DuracionAnuncio, modelo.PrecioPorSegundo, modelo.IdAnuncio });
            }
        }
Example #2
0
        public void Crear(AnuncioModelo modelo)
        {
            var consulta = "INSERT INTO Anuncio VALUES(@IdPrograma,@NifPatrocinador,@DuracionAnuncio,@PrecioPorSegundo)";

            using (var con = new SqlConnection(connectionString))
            {
                con.Execute(consulta, new { modelo.IdPrograma, modelo.NifPatrocinador, modelo.DuracionAnuncio, modelo.PrecioPorSegundo });
            }
        }
Example #3
0
 protected void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         var anuncioModelo = new AnuncioModelo();
         anuncioModelo.IdAnuncio        = int.Parse(hdfIdCadena.Value);
         anuncioModelo.DuracionAnuncio  = int.Parse(txtDuracionAnuncio.Text);
         anuncioModelo.PrecioPorSegundo = Convert.ToDecimal(txtPrecioPorSegundo.Text);
         anuncioServicio.Editar(anuncioModelo);
         Response.Redirect("Index.aspx", true);
     }
     catch (Exception)
     {
         CustomValidator err = new CustomValidator();
         err.IsValid      = false;
         err.ErrorMessage = "Ocurrio un error al editar el registro";
         Page.Validators.Add(err);
     }
 }
Example #4
0
        protected void btnCrear_Click(object sender, EventArgs e)
        {
            try
            {
                var anuncioModelo = new AnuncioModelo();

                anuncioModelo.IdPrograma       = Convert.ToInt32(txtIdPrograma.Text);
                anuncioModelo.NifPatrocinador  = txtNifRep.Text;
                anuncioModelo.DuracionAnuncio  = Convert.ToInt32(txtDuracionAnuncio.Text);
                anuncioModelo.PrecioPorSegundo = Convert.ToDecimal(txtPrecioPorSegundo.Text);

                anuncioServicio.Crear(anuncioModelo);
                Response.Redirect("Index.aspx", true);
            }
            catch (Exception ex)
            {
                CustomValidator err = new CustomValidator();
                err.IsValid      = false;
                err.ErrorMessage = "Ocurrio un error al insertar el registro" + ex.ToString();
                Page.Validators.Add(err);
            }
        }
Example #5
0
 public void Editar(AnuncioModelo modelo)
 {
     cadenaAnuncioRepositorio.Editar(modelo);
 }
Example #6
0
 public void Crear(AnuncioModelo modelo)
 {
     cadenaAnuncioRepositorio.Crear(modelo);
 }