public static async Task <bool> ValidateLibraryUser(LibraryUser myUser)
        {
            var filecontent = await FileHelper.ReadTextFileAsync(LOGIN_FILE_NAME);

            var lines = filecontent.Split(new char[] { '\r', '\n' });

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                var lineParts = line.Split(',');
                var LibUser   = new LibraryUser()
                {
                    UserName     = lineParts[0],
                    USerPassword = lineParts[1]
                };
                // Checking if the user object is in the Stored Login config file.
                if ((LibUser.UserName == myUser.UserName) && (LibUser.USerPassword == myUser.USerPassword))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        private void Next_Click(object sender, RoutedEventArgs e)
        {
            var myUser = new LibraryUser()
            {
                UserName     = UserNametxt.Text,
                USerPassword = Passwordtxt.Password
            };

            LibraryUser.WriteLibraryUserToFile(myUser);
            this.Frame.Navigate(typeof(MainPage));
        }
        private async void Login_Click(object sender, RoutedEventArgs e)
        {
            var myUser = new LibraryUser()
            {
                UserName     = txtUserName.Text,
                USerPassword = txtPassword.Password
            };

            if (await LibraryUser.ValidateLibraryUser(myUser))
            {
                this.Frame.Navigate(typeof(MyMusicCollection), myUser);
            }
            else
            {
                MainStatusText.Text = @" This login account doesnot exist.Enter a different account or create a new user";
            }
        }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            LibUserObject = (LibraryUser)e.Parameter;
            await MusicManager.GetAllMusic(MusicCollection);

            TxtUSER.Text = LibUserObject.UserName;
            // parameters.Name
            // parameters.Text
            // ...
            //LoadLibUserPlaylist(Userobject.UserName);
            // var MusicFileListOnload = MusicFile.LoadMyMusicCollection();
            // DataContext = MusicFile.LoadMyMusicCollection();
            //MusicList = await MusicManager.LoadMyMusicCollection();

            // MusicListToDisplay = await MusicManager.PickUsersMusicCollection();
            // MusicListToDisplay = await MusicManager.PickUsersMusicCollection();
            // DataContext= await MusicManager.PickUsersMusicCollection();
        }
        public static async Task <ICollection <LibraryUser> > GetLibraryUsers()
        {
            var LibUsersList = new List <LibraryUser>();
            var filecontent  = await FileHelper.ReadTextFileAsync(LOGIN_FILE_NAME);

            var lines = filecontent.Split(new char[] { '\r', '\n' });

            foreach (var line in lines)
            {
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                var lineParts = line.Split(',');
                var LibUser   = new LibraryUser()
                {
                    UserName     = lineParts[0],
                    USerPassword = lineParts[1]
                };
                LibUsersList.Add(LibUser);
            }
            return(LibUsersList);
        }
 protected async override void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     DataContext = await LibraryUser.GetLibraryUsers();
 }
        public static void WriteLibraryUserToFile(LibraryUser myUser)
        {
            var LibUserData = $"{myUser.UserName},{myUser.USerPassword}\n";

            FileHelper.WriteTextFileAsync(LOGIN_FILE_NAME, LibUserData);
        }