Beispiel #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;
        }
Beispiel #2
0
        public bool GetUsersData(out List<UserData> usersData, out string errorString)
        {
            usersData = null;
            errorString = string.Empty;

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

            List<User> users = null;
            if (!usersDataMan.GetUsers(out users, out errorString))
                return false;

            usersData = new List<UserData>();
            foreach (User user in users)
            {
                UserData userData = new UserData();
                userData.ID = user.UserId;
                userData.Name = user.Name;
                usersData.Add(userData);
            }

            return true;
        }