public Album Create(string albumName, string artistName, int genreId, Int16 price, System.Web.HttpPostedFileBase cover)
        {
            Album album = new Album
            {
                Name = albumName,
                Artist = ArtistRepository.CreateOrGet(artistName),
                GenreId = genreId,
                CreationDateTime = DateTime.Now,
                Price = price
            };

            AlbumRepository.Create(album);

            UploadResizeAndSave(ref album, cover);

            return album;
        }
 /// <summary>
 /// Create a new Album object.
 /// </summary>
 /// <param name="albumId">Initial value of the AlbumId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="artistId">Initial value of the ArtistId property.</param>
 /// <param name="creationDateTime">Initial value of the CreationDateTime property.</param>
 /// <param name="genreId">Initial value of the GenreId property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 public static Album CreateAlbum(global::System.Int32 albumId, global::System.String name, global::System.Int32 artistId, global::System.DateTime creationDateTime, global::System.Int32 genreId, global::System.Int16 price)
 {
     Album album = new Album();
     album.AlbumId = albumId;
     album.Name = name;
     album.ArtistId = artistId;
     album.CreationDateTime = creationDateTime;
     album.GenreId = genreId;
     album.Price = price;
     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);
 }
        public void UploadResizeAndSave(ref Album album, HttpPostedFileBase image = null)
        {
            string fileName = Guid.NewGuid() + Path.GetExtension(image.FileName);

            if (image != null)
            {
                image.SaveAs(HttpContext.Current.Server.MapPath("~/Content/Uploads/Temp/" + fileName));
            }

            try
            {
                foreach (var size in PictureSizes.Products)
                {
                    string nPath, nFileName;
                    PictureService.ResizeAndSave("~/Content/Uploads/Temp/", fileName, size.Width, size.Height, out nPath, out nFileName);

                    AlbumRepository.AddPicture(album.AlbumId, nPath, nFileName, size.Width, size.Height);
                }
            }
            finally
            {
                if (image != null)
                {
                    File.Delete(HttpContext.Current.Server.MapPath("~/Content/Uploads/Temp/" + fileName));
                }
            }
        }