public Team Add(Team team) { decimal id; _teamEngine.Add(team, out id); team.Id = id; return team; }
/// <summary> /// Adds a new team to the database. /// </summary> /// <param name="team">Team information.</param> /// <param name="id">Identifier of the team after the update is successful.</param> /// <returns></returns> public bool Add(Team team, out decimal id) { using (var dbCommand = DefaultDb.GetStoredProcCommand("Team_Add")) { DefaultDb.AddInParameter(dbCommand, "Shortname", DbType.String, team.Shortname); DefaultDb.AddInParameter(dbCommand, "Fullname", DbType.String, team.Fullname); DefaultDb.AddInParameter(dbCommand, "Logo", DbType.String, team.Logo); DefaultDb.AddOutParameter(dbCommand, "ID", DbType.Decimal, 0); DefaultDb.ExecuteNonQuery(dbCommand); id = DefaultDb.GetParameterValue(dbCommand, "ID") != DBNull.Value ? Convert.ToDecimal(DefaultDb.GetParameterValue(dbCommand, "ID")) : 0; return id > 0; } }
/// <summary> /// Updates the team with the new information. /// </summary> /// <param name="team">Modified details of the team.</param> /// <returns></returns> public bool Update(Team team) { using (var dbCommand = DefaultDb.GetStoredProcCommand("Team_Update")) { DefaultDb.AddInParameter(dbCommand, "ID", DbType.Decimal, team.Id); DefaultDb.AddInParameter(dbCommand, "Shortname", DbType.String, team.Shortname); DefaultDb.AddInParameter(dbCommand, "Fullname", DbType.String, team.Fullname); //DefaultDb.AddInParameter(dbCommand, "Logo", DbType.Decimal, team.Logo); var result = DefaultDb.ExecuteNonQuery(dbCommand); return result > 0; } }
public bool Update(Team team) { return _teamEngine.Update(team); }