public IHttpActionResult Insert(Persona requestDTO)
        {
            IHttpActionResult respuesta;
            ResponseDTO       responseDTO = new ResponseDTO();

            int    intNewId;
            string strErrores = "";

            //intNewId = PersonasService.Insert(newPersona);
            //intNewId = PersonasService.InsertScalar(newPersona);
            intNewId = PersonasService.InsertValid(requestDTO, out strErrores);

            if (intNewId > 0)
            {
                responseDTO.NewId = intNewId;
                respuesta         = Ok(responseDTO);
            }
            else
            {
                responseDTO.NewId   = 0;
                responseDTO.Errores = strErrores;
                respuesta           = Ok(responseDTO);
            }

            return(respuesta);
        }
Exemplo n.º 2
0
        protected void btnInsertar_Click(object sender, EventArgs e)
        {
            Persona newPersona;
            int     intNewId;
            string  strErrores = "";

            newPersona = new Persona();
            newPersona.Nombre   = txtNombre.Text;
            newPersona.Email    = txtEmail.Text;
            newPersona.Activo   = chkActivo.Checked;
            //intNewId = PersonasService.Insert(newPersona);
            //intNewId = PersonasService.InsertScalar(newPersona);
            intNewId = PersonasService.InsertValid(newPersona, out strErrores);

            if (intNewId > 0) {
                litOutput.Text = "Se inserto el ID:" + intNewId.ToString();
            } else {
                litOutput.Text = "Errores: " + strErrores;
            }
        }
        public ActionResult Create([Bind(Include = "Id,Nombre,Email,Activo")] Persona persona)
        {
            int    intNewId;
            string strErrores = "";

            if (ModelState.IsValid)
            {
                intNewId = PersonasService.InsertValid(persona, out strErrores);
                if (intNewId > 0)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Errores = strErrores;
                    return(View(persona));
                }
            }

            return(View(persona));
        }
Exemplo n.º 4
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            Persona newPersona;
            int     intNewId;
            string  strErrores = "";

            newPersona        = new Persona();
            newPersona.Nombre = txtNombre.Text;
            newPersona.Email  = txtEmail.Text;
            newPersona.Activo = chkActivo.Checked;
            //intNewId = PersonasService.Insert(newPersona);
            //intNewId = PersonasService.InsertScalar(newPersona);
            intNewId = PersonasService.InsertValid(newPersona, out strErrores);
            if (intNewId > 0)
            {
                MessageBox.Show("Se inserto el ID:" + intNewId.ToString());
            }
            else
            {
                MessageBox.Show("Errores: " + strErrores);
            }
        }