public bool SaveImage(int albumId, ImageFileData imageFileData, out string url) { Album album = context.Albums.Find(albumId); if (album == null) { url = ""; return false; } AlbumImageData imageToAdd = new AlbumImageData() { AlbumId = albumId }; context.AlbumImages.Add(imageToAdd); context.SaveChanges(); #warning yossim: jpg extension shouldn't be hard coded imageToAdd.URL = ImageStoreUtilities.GenerateUrl(albumId, imageToAdd.AlbumImageDataId, ".jpg"); { #warning yossim: Should be transactive ImageStoreUtilities.Store(imageToAdd.URL,imageFileData.ImageStream); context.SaveChanges(); } url = imageToAdd.URL; return true; }
public bool AddImage(int albumId, ImageFileData imageFileData, out string errorString) { IAlbumsDataManager albumsDataMan = managersFactory.CreateAlbumsManager(); if (albumsDataMan == null) { errorString = "Failed retrieving AlbumsDataManager"; return false; } IImagesManager imagesMan = managersFactory.CreateImagesManager(); if (imagesMan == null) { errorString = "Failed retrieving ImagesManager"; return false; } string url; if (!imagesMan.SaveImage(albumId, imageFileData, out url)) { errorString = "Failed saving image"; return false; } errorString = ""; return true; }