コード例 #1
0
        private async void Button_Login(object sender, RoutedEventArgs e)
        {
            string email    = txtEmail.Text;
            string password = txtPassword.Password;
            var    errors   = validateLogin(email, password);

            if (errors.Count > 0)
            {
                Erremail.Text    = errors.ContainsKey("email") ? errors["email"] : "";
                Errpassword.Text = errors.ContainsKey("password") ? errors["password"] : "";
            }
            else
            {
                string token = await _service.Login(email, password);

                if (!token.Equals("error"))
                {
                    var write = Task.Run(async() => await HandlerFileService.WriteFile("token.txt", token)).Result;
                    App.token = Task.Run(async() => await HandlerFileService.ReadFile("token.txt")).Result;
                    Navigatior.GetCurrent().SetSelectedNavigationItem(2);
                }
                else
                {
                    this.status      = true;
                    statusLogin.Text = "Invalid Infomation";
                    Erremail.Text    = "";
                    Errpassword.Text = "";
                }
            }
        }
コード例 #2
0
        private Member getInfo()
        {
            Task <string> tokenTask = Task.Run(async() => await HandlerFileService.ReadFile("token.txt"));
            string        token     = tokenTask.Result;

            if (token.Length > 0)
            {
                Task <Member> member       = Task.Run(async() => await _service.GetMemberInformation(token));
                Member        memberResult = member.Result;
                return(memberResult);
            }
            else
            {
                Navigatior.GetCurrent().SetSelectedNavigationItem(2);
            }

            return(null);
        }
コード例 #3
0
        private async void Button_Register(object sender, RoutedEventArgs e)
        {
            var member = new Member()
            {
                firstName = TxtFirstName.Text,
                lastName  = TxtLastName.Text,
                password  = PwdPassword.Password,
                address   = TxtAddress.Text,
                phone     = TxtPhone.Text,
                avatar    = TxtAvatar.Text,
                gender    = _choosedGender,
                email     = TxtEmail.Text,
                birthday  = _birthday,
            };

            var errors = member.CheckValidate(CfPassword.Password);

            if (errors.Count > 0)
            {
                ErrFirstName.Text  = errors.ContainsKey("firstName") ? errors["firstName"] : "";
                ErrLastName.Text   = errors.ContainsKey("lastName") ? errors["lastName"] : "";
                ErrAddress.Text    = errors.ContainsKey("address") ? errors["address"] : "";
                ErrPassword.Text   = errors.ContainsKey("password") ? errors["password"] : "";
                ErrEmail.Text      = errors.ContainsKey("email") ? errors["email"] : "";
                ErrAvatar.Text     = errors.ContainsKey("avatar") ? errors["avatar"] : "";
                ErrBirtDay.Text    = errors.ContainsKey("birthday") ? errors["birthday"] : "";
                ErrPhone.Text      = errors.ContainsKey("phone") ? errors["phone"] : "";
                ErrCfPassword.Text = errors.ContainsKey("confirmPassword") ? errors["confirmPassword"] : "";
                ErrGender.Text     = errors.ContainsKey("gender") ? errors["gender"] : "";
            }
            else
            {
                bool status = await this._service.Register(member);

                if (status)
                {
                    Navigatior.GetCurrent().SetSelectedNavigationItem(0);
                }
            }
        }
コード例 #4
0
        private async void Button_Register(object sender, RoutedEventArgs e)
        {
            var song = new Song
            {
                name      = songName.Text,
                author    = author.Text,
                singer    = singerName.Text,
                thumbnail = thumbnail.Text,
            };
            var errors = song.CheckValidate();

            if (fileSlected == null)
            {
                errors.Add("ErrFile", "File is required!");
            }
            if (errors.Count > 0 && fileSlected == null)
            {
                ErSongName.Text    = errors.ContainsKey("Name") ? errors["Name"] : "";
                ErrSingerName.Text = errors.ContainsKey("Singer") ? errors["Singer"] : "";
                ErrAuthor.Text     = errors.ContainsKey("Author") ? errors["Author"] : "";
                ErrThumbnail.Text  = errors.ContainsKey("Thumbnail") ? errors["Thumbnail"] : "";
                ErrFile.Text       = errors.ContainsKey("ErrFile") ? errors["ErrFile"] : "";
            }
            else
            {
                var url = await _service.postFile(fileSlected);

                if (url.Equals(""))
                {
                    ErrFile.Text = "Error link!";
                    return;
                }
                song.link = url;
                bool status = _service.RegisterSong(song, App.token);
                if (status)
                {
                    Navigatior.GetCurrent().SetSelectedNavigationItem(3);
                }
            }
        }
コード例 #5
0
 private void Button_Cancel(object sender, RoutedEventArgs e)
 {
     Navigatior.GetCurrent().SetSelectedNavigationItem(2);
 }