public IList <IArtistContact> GetTop <IArtistQueryParams>(int top, IArtistQueryParams query) { _collection = new List <IArtistContact>(); string sqlCommand = "artistContactGetTop"; using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { _dataBase.AddInParameter(dbCmd, "@topParam", DbType.Int32, top); _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy); using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { IArtistContact artistContact = new ArtistContact(); artistContact.IdArtistContact = Convert.ToInt32(reader["idArtistContact"].ToString()); artistContact.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); artistContact.Email = reader["email"].ToString(); artistContact.Facebook = reader["facebook"].ToString(); artistContact.Soundcloud = reader["soundcloud"].ToString(); artistContact.Tumblr = reader["tumblr"].ToString(); artistContact.Twitter = reader["twitter"].ToString(); artistContact.Website = reader["website"].ToString(); artistContact.Bandcamp = reader["bandcamp"].ToString(); _collection.Add(artistContact); } } } return(_collection); }
public IArtistContact GetById(int id) { IArtistContact artistContact = new ArtistContact(); string sqlCommand = "artistContactFind"; using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { IDataQuery query = new DataQuery(); query.Where = string.Format(" idArtistContact={0} ", id); _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, query.From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, query.Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, query.OrderBy); using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { artistContact.IdArtistContact = Convert.ToInt32(reader["idArtistContact"].ToString()); artistContact.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); artistContact.Email = reader["email"].ToString(); artistContact.Facebook = reader["facebook"].ToString(); artistContact.Soundcloud = reader["soundcloud"].ToString(); artistContact.Tumblr = reader["tumblr"].ToString(); artistContact.Twitter = reader["twitter"].ToString(); artistContact.Website = reader["website"].ToString(); artistContact.Bandcamp = reader["bandcamp"].ToString(); } } } return(artistContact); }
public IList <IArtistContact> Find <IArtistQueryParams>(IArtistQueryParams query) { _collection = new List <IArtistContact>(); string sqlCommand = "artistContactFind"; // Create a suitable command type and add the required parameter. using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { _dataBase.AddInParameter(dbCmd, "@fromParam", DbType.String, ((IDataQuery)query).From); _dataBase.AddInParameter(dbCmd, "@whereParam", DbType.String, ((IDataQuery)query).Where); _dataBase.AddInParameter(dbCmd, "@orderByParam", DbType.String, ((IDataQuery)query).OrderBy); // Call the ExecuteReader method with the command. using (IDataReader reader = _dataBase.ExecuteReader(dbCmd)) { while (reader.Read()) { IArtistContact artistContact = new ArtistContact(); artistContact.IdArtistContact = Convert.ToInt32(reader["idArtistContact"].ToString()); artistContact.ArtistId = Convert.ToInt32(reader["artistId"].ToString()); artistContact.Email = reader["email"].ToString(); artistContact.Facebook = reader["facebook"].ToString(); artistContact.Soundcloud = reader["soundcloud"].ToString(); artistContact.Tumblr = reader["tumblr"].ToString(); artistContact.Twitter = reader["twitter"].ToString(); artistContact.Website = reader["website"].ToString(); artistContact.Bandcamp = reader["bandcamp"].ToString(); _collection.Add(artistContact); } } } return(_collection); }
public IArtistContact Update(IArtistContact artist) { IArtistContact artistContactUpdated = new ArtistContact(); string sqlCommand = "artistUpdate"; using (DbCommand dbCmd = _dataBase.GetStoredProcCommand(sqlCommand)) { _dataBase.AddInParameter(dbCmd, "@idartistcontact", DbType.Int32, artistContactUpdated.IdArtistContact); _dataBase.AddInParameter(dbCmd, "@artistId", DbType.Int32, artistContactUpdated.ArtistId); _dataBase.AddInParameter(dbCmd, "@bandcamp", DbType.String, artistContactUpdated.Bandcamp); _dataBase.AddInParameter(dbCmd, "@website", DbType.String, artistContactUpdated.Website); _dataBase.AddInParameter(dbCmd, "@facebook", DbType.String, artistContactUpdated.Facebook); _dataBase.AddInParameter(dbCmd, "@tumblr", DbType.String, artistContactUpdated.Tumblr); _dataBase.AddInParameter(dbCmd, "@email", DbType.String, artistContactUpdated.Email); _dataBase.AddInParameter(dbCmd, "@soundcloud", DbType.String, artistContactUpdated.Soundcloud); _dataBase.AddInParameter(dbCmd, "@twitter", DbType.String, artistContactUpdated.Twitter); _dataBase.ExecuteScalar(dbCmd); artistContactUpdated = this.GetById(artist.ArtistId); } return(artistContactUpdated); }