/// <summary>
        /// Delete a Album by the primary key
        /// </summary>
        /// <param name="album"></param>
        public int Delete(Album album, string commandText)
        {
            DbParameter[] parameters =
            {
                DbClient.MakeParameter("@AlbumID",DbType.Int32,4,album.AlbumID),

            };

            return DbClient.NonQuery(commandText, parameters);
        }
        /// <summary>
        /// Handles the Click event of the addAlbum control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void addAlbum_Click(object sender, EventArgs e)
        {
            Album album = new Album {Name = albumName.Text.Trim(), Description = description.Text.Trim(), UserId = CurrentUser.UserId};
            AlbumLogic.Add(album);

            message.Text = string.Format(AdminResources.SuccessfulAlbumAdd, album.Name);

            //Clears the textboxes
            WebControlUtilities.ClearTextFromControl<TextBox>(Controls);
        }
        /// <summary>
        /// Inserts Album into the Albums Table
        /// </summary>
        /// <param name="album">A new populated album.</param>
        /// <returns>Insert Count</returns>
        public int Insert(Album album, string commandText)
        {
            DbParameter[] parameters =
            {
                    DbClient.MakeParameter("@Name",DbType.String,50,album.Name),
                    DbClient.MakeParameter("@Description",DbType.String,255,album.Description),
                    DbClient.MakeParameter("@UserId",DbType.Int32,4,album.UserId)

            };

            return DbClient.NonQuery(commandText, parameters);
        }
        /// <summary>
        /// Populates the specified reader.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        internal Album Populate(SqlDataReader reader)
        {
            Album album = new Album();

            using (reader)
            {
                while (reader.Read())
                {
                    album = GetItem(reader);
                }
            }

            return album;
        }
        /// <summary>
        /// Updates the Album table by the primary key, if the Album is dirty then an update will occur
        /// </summary>
        /// <param name="album">a populated album</param>
        /// <returns>update count</returns>
        public int Update(Album album, string commandText)
        {
            int updateCount = 0;

            if(album.IsDirty())
            {
                DbParameter[] parameters =
                {
                    DbClient.MakeParameter("@AlbumID",DbType.Int32,4,album.AlbumID),
                    DbClient.MakeParameter("@Name",DbType.String,50,album.Name),
                    DbClient.MakeParameter("@Description",DbType.String,150,album.Description),
                    DbClient.MakeParameter("@UserId",DbType.Int32,4,album.UserId)

                };

                updateCount = DbClient.NonQuery(commandText, parameters);

            }

            return updateCount;
        }
 /// <summary>
 /// Updates the Album by the ablum ID
 /// </summary>
 /// <param name="album">Desired changes</param>
 public static void Update(Album album)
 {
     IAlbum userResource = Resource.GetResource<IAlbum>();
     userResource.Update(album);
 }
 /// <summary>
 /// Delete a single Album
 /// </summary>
 /// <param name="album"></param>
 public static void Delete(Album album)
 {
     IAlbum userResource = Resource.GetResource<IAlbum>();
     userResource.Delete(album);
 }
 /// <summary>
 /// Add new Album
 /// </summary>
 /// <param name="album"></param>
 public static void Add(Album album)
 {
     IAlbum userResource = Resource.GetResource<IAlbum>();
     userResource.Insert(album);
 }
 /// <summary>
 /// Updates the Album table by the primary key, if the Album is dirty then an update will occur
 /// </summary>
 /// <param name="album">a populated album</param>
 /// <returns>update count</returns>
 public int Update(Album album)
 {
     return albumDb.Update(album, "Album_Update");
 }
Example #10
0
 /// <summary>
 /// Inserts Album into the Albums Table
 /// </summary>
 /// <param name="album">A new populated album.</param>
 /// <returns>Insert Count</returns>
 public int Insert(Album album)
 {
     return albumDb.Insert(album, "Album_Insert");
 }
Example #11
0
 /// <summary>
 /// Delete a Album by the primary key
 /// </summary>
 /// <param name="album"></param>
 public int Delete(Album album)
 {
     return albumDb.Delete(album, deleteMethod);
 }
        /// <summary>
        /// Gets the item.
        /// </summary>
        /// <param name="reader">The reader.</param>
        /// <returns></returns>
        private Album GetItem(IDataRecord reader)
        {
            Album album = new Album
                              {
                                  AlbumID = Convert.ToInt32(reader["AlbumID"]),
                                  Name = Convert.ToString(reader["Name"]),
                                  Description = Convert.ToString(reader["Description"]),
                                  UserId = Convert.ToInt32(reader["UserId"])
                              };

            return album;
        }
 /// <summary>
 /// Updates the Album table by the primary key, if the Album is dirty then an update will occur
 /// </summary>
 /// <param name="album">a populated album</param>
 /// <returns>update count</returns>
 public int Update(Album album)
 {
     const string sql = "Update Album SET Name = @Name, 	Description = @Description, UserId = @UserId Where AlbumID = @AlbumID";
     return albumDb.Update(album, sql);
 }
 /// <summary>
 /// Inserts Album into the Albums Table
 /// </summary>
 /// <param name="album">A new populated album.</param>
 /// <returns>Insert Count</returns>
 public int Insert(Album album)
 {
     const string sql = "INSERT INTO Album (Name, Description, UserId) VALUES (@Name, @Description, @UserId)";
     return albumDb.Insert(album, sql);
 }