Ejemplo n.º 1
0
 public async Task<bool> LoginAccount(string mail,string password)
 {            
     byte[] pwd = Functions.GetBytes(password);
     Account account = new Account(mail, pwd);
     JToken body = JToken.FromObject(account);
     _userInfo = new UserInfo();
     IDictionary<string, string> argument = new Dictionary<string, string>
     {
         {"type" , "Test"}
     };
     try
     {
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             var result = await App.MobileService.InvokeApiAsync("Users", body, HttpMethod.Post, argument);
             JObject user = JObject.Parse(result.ToString());
             UserInfo = user.ToObject<UserInfo>();             
             PaybayPushClient.UploadChannel(UserInfo.UserId);                    
             MessageInboxViewModel.registerClient();
             //MediateClass.MessageVM = new MessageInboxViewModel();
             //MediateClass.MessageVM.registerClient();      
         }
         else
         {
             await new MessageDialog("You have not internet connection!Can not login!","Login").ShowAsync();
             return false;
         }
     }
     catch (Exception ex)
     {                
         return false;
     }
     return true;               
 }
Ejemplo n.º 2
0
        public async Task ResetPasswordOfUser(string email)
        {
            string newPass = "******";
            byte[] newPwd = Functions.GetBytes(newPass);

            Account account = new Account(email, newPwd, newPass);
            JToken body = JToken.FromObject(account);

            IDictionary<string, string> param = new Dictionary<string, string>
            {
                {"code" , "1"}
            };

            try
            {
                var result = await App.MobileService.InvokeApiAsync("Users", body, HttpMethod.Put, param);
                if (result["ErrCode"].ToString().Equals("1"))
                {
                    await new MessageDialog("Reset password is successful.Please check your email!", "Notification!").ShowAsync();
                }
                else
                {
                    await new MessageDialog("Email is NOT exists!Please check again!", "Notification!").ShowAsync();
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
            }
        }