Example #1
0
        private void ButtonLogin_Click(object sender, RoutedEventArgs e)
        {
            var         errors = new Dictionary <string, string>();
            MemberLogin mem    = new MemberLogin
            {
                email    = this.email.Text,
                password = this.password.Password
            };

            errors = mem.Validate();
            if (errors.Count == 0)
            {
                string token = memberService.Login(this.email.Text, this.password.Password);
                if (token == null)
                {
                    //Show errors
                }
                else
                {
                    //Show success
                    //Lay info tu APi bang token:
                    Member memberLogin = memberService.GetInformation(token);
                    MemberLoginAction.ShowMenuIfLogged();
                    Frame.Navigate(typeof(MySong));
                }
            }
            else
            {
                ShowError(errors);
            }
        }
Example #2
0
 public Upload()
 {
     this.memberService = new MemberServiceImp();
     loginToken         = memberService.ReadTokenFromLocalStorage();
     if (loginToken == null)
     {
         //Not login:
         MemberLoginAction.HideMenuIfLogged();
     }
     else
     {
         this.InitializeComponent();
         this.songService = new SongServiceImp();
     }
 }
Example #3
0
        public NaView()
        {
            this.InitializeComponent();
            uploadNav   = this.upload;
            mysongNav   = this.mysong;
            listsongNav = this.listsong;
            profileNav  = this.profile;

            memberService = new MemberServiceImp();
            tokenLogin    = memberService.ReadTokenFromLocalStorage();
            if (tokenLogin == null)
            {
                MemberLoginAction.HideMenuIfLogged();
            }
            else
            {
                Member memberLogin = memberService.GetInformation(tokenLogin);
            }
        }
Example #4
0
 public MySong()
 {
     this.memberService = new MemberServiceImp();
     loginToken         = memberService.ReadTokenFromLocalStorage();
     if (loginToken == null)
     {
         MemberLoginAction.HideMenuIfLogged();
     }
     else
     {
         this.InitializeComponent();
         this.songService = new SongServiceImp();
         LoadSongs();
         if (_songs.Count == 0)
         {
             this.empty.Visibility = Visibility.Visible;
             this.media.Visibility = Visibility.Collapsed;
         }
     }
 }
Example #5
0
        private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
        {
            var errors = new Dictionary <string, string>();
            var member = new Member
            {
                firstName    = this.firstname.Text,
                lastName     = this.lastname.Text,
                password     = this.password.Password,
                address      = this.address.Text,
                avatar       = imgUrl,
                birthday     = this.birthday.Date.ToString("yyyy-MM-dd"),
                email        = this.email.Text,
                gender       = (int)this.gender.SelectedValue,
                introduction = this.introduction.Text,
                phone        = this.phone.Text
            };

            Debug.WriteLine("Birthday: " + member.birthday);

            errors = member.Validate();
            if (errors.Count == 0)
            {
                var memberRes = memberService.Register(member);
                if (memberRes == null)
                {
                    //Show error
                }
                else
                {
                    //Show success
                    var token = memberService.Login(this.email.Text, this.password.Password);
                    MemberLoginAction.ShowMenuIfLogged();
                    Frame.Navigate(typeof(ListSong));
                }
            }
            else
            {
                ShowError(errors);
            }
        }
Example #6
0
 public Profile()
 {
     memberService = new MemberServiceImp();
     loginToken    = memberService.ReadTokenFromLocalStorage();
     if (loginToken == null)
     {
         MemberLoginAction.HideMenuIfLogged();
     }
     else
     {
         this.InitializeComponent();
         memLogged = memberService.GetInformation(loginToken);
         if (memLogged.gender == 0)
         {
             this.gender.Text = "Female";
         }
         else if (memLogged.gender == 1)
         {
             this.gender.Text = "Male";
         }
         DateTime dt = DateTime.Parse(memLogged.birthday);
         this.birthday.Text = String.Format("{0:ddd, MMM d, yyyy}", dt);
     }
 }