public JsonResult GuardarEspecie(EspeciesBO model)
        {
            var result = false;

            try
            {
                if (model.id > 0)
                {
                    objEspeciesDAO.ActualizarEspecie(model);
                    result = true;
                }
                else
                {
                    objEspeciesDAO.AgregarEspecie(model);
                    result = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            var json = Json(result, JsonRequestBehavior.AllowGet);

            json.MaxJsonLength = Int32.MaxValue;
            return(json);
        }
Example #2
0
        public int AgregarEspecie(EspeciesBO objBO)
        {
            SqlCommand cmd = new SqlCommand("INSERT INTO Especie (nomCientifico, nomComun) VALUES(@nomCientifico,@nomComun)");

            cmd.Parameters.Add("@nomCientifico", SqlDbType.VarChar).Value = objBO.nomCientifico;
            cmd.Parameters.Add("@nomComun", SqlDbType.VarChar).Value      = objBO.nomComun;

            return(con.EjecutarComando(cmd));
        }
Example #3
0
        public int ActualizarEspecie(EspeciesBO objBO)
        {
            SqlCommand cmd = new SqlCommand("UPDATE Especie SET nomCientifico=@nomCientifico,nomComun=@nomComun WHERE id=@id");

            cmd.Parameters.Add("@nomCientifico", SqlDbType.VarChar).Value = objBO.nomCientifico;
            cmd.Parameters.Add("@nomComun", SqlDbType.VarChar).Value      = objBO.nomComun;
            cmd.Parameters.Add("@id", SqlDbType.Int).Value = objBO.id;

            return(con.EjecutarComando(cmd));
        }