private Asset CreateAsset(Album album, string fileName)
        {
            var extension = fileName.Split('.')[1];

            if (album != null && album.IsProfilePictureAlbum)
            {
                //if the profile pic album, delete all images before saving to
                int i = album.Assets.Count - 1;
                while (album.Assets.Count > 0)
                {
                    DataContext.Assets.DeleteObject(album.Assets.ElementAt(i));
                    i--;
                }

                DataContext.SaveChanges();
            }

            var asset = new Asset()
            {
                Album = album,
                Type = extension.ToLower()
            };
            DataContext.Assets.AddObject(asset);
            DataContext.SaveChanges();
            return asset;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     var user = CurrentUser;
     var albumId = long.Parse(Request.QueryString["AlbumId"]);
     album = LoadAlbum(albumId);
     if(!album.Child.UserIsAuthorizedForChild(user))
         throw new UnauthorizedAccessException();
 }
 private Asset CreateAsset(Album album, string fileName)
 {
     var extension = fileName.Split('.')[1];
     var asset = new Asset()
     {
         Album = album,
         Type = extension
     };
     DataContext.Assets.AddObject(asset);
     DataContext.SaveChanges();
     return asset;
 }
        private Album EditOrCreateAlbum(string id)
        {
            Album album = null;

            if(!string.IsNullOrEmpty(id))
                album = LoadAlbum(long.Parse(id));

            if (album == null)
            {
                album = new Album()
                {
                    Child = _child
                };
                DataContext.Albums.AddObject(album);
            }

             album.Title = AlbumTitle.Text;
             album.Description = AlbumDescription.Text;
             return album;
        }
 /// <summary>
 /// Create a new Album object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="childId">Initial value of the ChildId property.</param>
 /// <param name="isImportanDocumentsAlbum">Initial value of the IsImportanDocumentsAlbum property.</param>
 /// <param name="isProfilePictureAlbum">Initial value of the IsProfilePictureAlbum property.</param>
 public static Album CreateAlbum(global::System.Int64 id, global::System.Int64 childId, global::System.Boolean isImportanDocumentsAlbum, global::System.Boolean isProfilePictureAlbum)
 {
     Album album = new Album();
     album.ID = id;
     album.ChildId = childId;
     album.IsImportanDocumentsAlbum = isImportanDocumentsAlbum;
     album.IsProfilePictureAlbum = isProfilePictureAlbum;
     return album;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Albums EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAlbums(Album album)
 {
     base.AddObject("Albums", album);
 }