コード例 #1
0
        /// <summary>
        /// Loads a new instance of the CustomerAlbum class from the database
        /// </summary>
        /// <param name="customerAlbumId">Unique identifier of the album</param>
        /// <param name="customerId">Unique identifier of the customer the album belongs to</param>
        public CustomerAlbum(Int16 customerAlbumId, Guid customerId)
        {
            CustomerAlbum clone = Data.CustomerAlbum.GetCustomerAlbumById(customerAlbumId, customerId);

            this.Id           = clone.Id;
            this.customerId   = clone.customerId;
            this.customer     = clone.customer;
            this.Name         = clone.Name;
            this.Description  = clone.Description;
            this.Images       = clone.Images;
            this.DateCreated  = clone.DateCreated;
            this.IsInDatabase = true;
        }
コード例 #2
0
ファイル: User.cs プロジェクト: johnlace1986/DropboxProjects
        /// <summary>
        /// Removes an album from the albums array
        /// </summary>
        /// <param name="customerAlbum">Album being removed</param>
        internal void RemoveAlbum(CustomerAlbum customerAlbum)
        {
            if (!(IsInDatabase))
            {
                throw new Exception.DbObjectNotInDatabaseException("Cannot remove an album from a user that does not exist in the database");
            }

            if (!(customerAlbum.IsInDatabase))
            {
                throw new Exception.DbObjectNotInDatabaseException("Cannot remove an ablum that does not exist in the database from a user");
            }

            if (customerAlbum.customerId != UserId)
            {
                throw new Exception.ChildBelongsToDifferentParentException("Cannot remove the album from the user. The album belongs to another user");
            }

            List <CustomerAlbum> albums = new List <CustomerAlbum>();
            Boolean blnFound            = false;

            foreach (CustomerAlbum album in CustomerAlbums)
            {
                if (album.Id == customerAlbum.Id)
                {
                    blnFound = true;
                }
                else
                {
                    albums.Add(album);
                }
            }

            if (!(blnFound))
            {
                throw new Exception.ChildDoesNotBelongToParentException("The user does not own the album");
            }

            CustomerAlbums = albums.ToArray();
        }