public JsonResult GuardarRaza(RazasBO model) { var result = false; try { if (model.id > 0) { objRazasDAO.ActulizarRazo(model); result = true; } else { objRazasDAO.AgregarRaza(model); result = true; } } catch (Exception ex) { throw ex; } var json = Json(result, JsonRequestBehavior.AllowGet); json.MaxJsonLength = Int32.MaxValue; return(json); }
public int AgregarRaza(RazasBO objBO) { SqlCommand cmd = new SqlCommand("INSERT INTO Raza(nombre, idEspecie) VALUES(@nombre,@idEspecie)"); cmd.Parameters.Add("@nombre", SqlDbType.VarChar).Value = objBO.nombre; cmd.Parameters.Add("@idEspecie", SqlDbType.Int).Value = objBO.idEspecie; return(con.EjecutarComando(cmd)); }
public int ActulizarRazo(RazasBO objBO) { SqlCommand cmd = new SqlCommand("UPDATE Raza SET nombre=@nombre,idEspecie=@idEspecie WHERE id=@id"); cmd.Parameters.Add("@nombre", SqlDbType.VarChar).Value = objBO.nombre; cmd.Parameters.Add("@idEspecie", SqlDbType.Int).Value = objBO.idEspecie; cmd.Parameters.Add("@id", SqlDbType.Int).Value = objBO.id; return(con.EjecutarComando(cmd)); }