Exemplo n.º 1
0
        public bool GetUserData(int userId,out UserData userData,out String errorString)
        {
            IUsersDataManager usersDataMan = managersFactory.CreateUsersDataManagerr();
            User user = usersDataMan.GetUser(userId);

            if(user == null)
            {
                errorString = "User not found";
                userData = null;
                return false;
            }

            userData = new UserData();
            userData.ID = user.UserId;
            userData.Name = user.Name;
            userData.Albums = new List<AlbumData>();
            foreach (var album in user.Albums)
            {
                AlbumData albumData = new AlbumData();
                albumData.ID = album.AlbumId;
                albumData.Name = album.Name;
                albumData.Images = new List<ImageData>();
                foreach(var albumImageData in album.ImagesData)
                {
                    ImageData imageData = new ImageData();
                    imageData.ID = albumImageData.AlbumImageDataId;
                    imageData.URL = albumImageData.URL;
                    Image image = Image.FromFile(albumImageData.URL);
                    imageData.Height = image.Height;
                    imageData.Width = image.Width;
                    albumData.Images.Add(imageData);
                }
                userData.Albums.Add(albumData);
            }
            errorString = "";
            return true;
        }
Exemplo n.º 2
0
        public bool GetAlbumsData(int userId, out List<AlbumData> albumsData, out string errorString)
        {
            albumsData = null;
            errorString = string.Empty;

            IUsersDataManager usersDataMan = managersFactory.CreateUsersDataManagerr();
            if (usersDataMan == null)
            {
                errorString = "Failed retrieving UsersDataManager";
                return false;
            }

            List<int> albumIds = null;
            if (!usersDataMan.GetAlbumIDs(userId, out albumIds, out errorString))
                return false;

            IAlbumsDataManager albumsDataMan = managersFactory.CreateAlbumsManager();
            if (albumsDataMan == null)
            {
                errorString = "Failed retrieving AlbumsDataManager";
                return false;
            }

            List<Album> albums = null;
            if (!albumsDataMan.GetAlbums(albumIds, out albums, out errorString))
                return false;

            albumsData = new List<AlbumData>();
            foreach (Album album in albums)
            {
                AlbumData albumData = new AlbumData();
                albumData.ID = album.AlbumId;
                albumData.Name = album.Name;

                albumsData.Add(albumData);
            }            

            return true;
        }