コード例 #1
0
		async partial void btnCreateAccount_TouchUpInside (UIButton sender){
			HttpClientFactory factory = new HttpClientFactory();
			UserRepository repository = new UserRepository(factory);

			RegisterViewModel.Email = txtEmail.Text;
			RegisterViewModel.Password = txtPassword.Text;
			RegisterViewModel.ConfirmPassword = txtConfirm.Text;

			if(RegisterViewModel.Password == RegisterViewModel.ConfirmPassword){
				User user = await repository.RegisterAsync(RegisterViewModel);

				if(user != null)
				{
					var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;
					var mainStoryBoard = appDelegate.MainStoryBoard;
					var tabBarController = appDelegate.GetViewController(mainStoryBoard, "MainTabBarController");
					ProfileViewController profileViewController = tabBarController.ChildViewControllers[1] as ProfileViewController;
					profileViewController.CurrentUser = user;

					appDelegate.SetRootViewController(profileViewController, true);
				}
				else{
					new UIAlertView("Registration Error", "Please try again", null, "OK", null);
				}

			}
			else{
				
			}
		}
コード例 #2
0
		private async Task<User> SaveProfile()
		{
			CurrentUser.FirstName = txtFirstName.Text;
			CurrentUser.LastName = txtLastName.Text;
			CurrentUser.Email = txtEmail.Text;
			CurrentUser.UserName = txtEmail.Text;
			CurrentUser.PhoneNumber = txtMobilePhone.Text;

			if (originalImage != null) {
				byte[] imgArray = ImageConverter.ToNSData (originalImage); 
				CurrentUser.ProfilePicture = System.Convert.ToBase64String(imgArray); //Convert for JSON
			}

			HttpClientFactory client =new HttpClientFactory(CurrentUser.UserAccessToken);
			UserRepository repository = new UserRepository(client);

			User user = await repository.UpdateAsync(CurrentUser);
			user.UserAccessToken = CurrentUser.UserAccessToken;

			if (user != null) {
				return user;
			} else {
				return null;
			}
		}