public Leapee UpdateLeapee(Leapee leapeeToUpdate) { using (var db = new SqlConnection(ConnectionString)) { var rowsAffected = db.Execute(@"Update Leapees Set name = @name Where Id = @id", leapeeToUpdate); if (rowsAffected == 1) { return(leapeeToUpdate); } } throw new Exception("Could not update leapee."); }
public Leapee UpdateLeapee(Leapee leapeeToUpdate) { using (var db = new SqlConnection(ConnectionString)) { var updateQuery = @" UPDATE Leapees SET Name = @name WHERE id = @id"; var rowsAffected = db.Execute(updateQuery, leapeeToUpdate); if (rowsAffected == 1) { return(leapeeToUpdate); } } throw new Exception("Could not update leapee"); }