public Leaper UpdateLeaper(Leaper leaperToUpdate) { using (var db = new SqlConnection(ConnectionString)) { var rowsAffected = db.Execute(@"Update Leapers Set name = @name, budget = @budget Where Id = @id", leaperToUpdate); if (rowsAffected == 1) { return(leaperToUpdate); } } throw new Exception("Could not update leaper."); }
public Leaper UpdateBudget(Leaper leaperToUpdate) { using (var db = new SqlConnection(ConnectionString)) { var updateQuery = @" Update leaper Set Budget = Budget - 10000 Where Id = @id"; var rowsAffected = db.Execute(updateQuery, leaperToUpdate); if (rowsAffected == 1) { return(leaperToUpdate); } } throw new Exception("Could not update leaper's budget"); }
public Leaper UpdateLeaper(Leaper leaperToUpdate) { using (var db = new SqlConnection(ConnectionString)) { var updateQuery = @" UPDATE Leapers SET Name = @name, Budget = @budget WHERE id = @id"; var rowsAffected = db.Execute(updateQuery, leaperToUpdate); if (rowsAffected == 1) { return(leaperToUpdate); } } throw new Exception("Could not update leaper"); }
public void Add(Leaper leaper) { _leapers.Add(leaper); }