コード例 #1
0
ファイル: AccountService.cs プロジェクト: pabalexa/Moments
		public async Task Register (Account account, User user)
		{
			using (var client = MobileServiceClientFactory.CreateClient ()) {
				await client.GetTable<User> ().InsertAsync (user);
			}

			account.UserId = user.Id;

			await Insert (account, false);
		}
コード例 #2
0
ファイル: SignUpViewModel.cs プロジェクト: pabalexa/Moments
		private async Task ExecuteSignUpUserCommand ()
		{
			if (IsBusy) {
				return;
			}

			IsBusy = true;

			var user = new User {
				Name = string.Format ("{0} {1}", FirstName, LastName),
				ProfileImage = GravatarService.CalculateUrl (Email)
			};

			var account = new Account {
				Username = Username,
				Password = Password,
				Email = Email,
				UserId = user.Id
			};
		
			try
			{
				DialogService.ShowLoading (Strings.CreatingAccount);
				if (await ConnectivityService.IsConnected ()) {
					await CreateAccount (account, user);

					await SignIn (account);
					NavigateToMainUI ();

					DialogService.HideLoading ();
				} else {
					DialogService.ShowError (Strings.NoInternetConnection);
				}
			}
			catch (Exception ex) 
			{
				Insights.Report (ex);
			}

			IsBusy = false;
		}
コード例 #3
0
ファイル: FriendService.cs プロジェクト: pabalexa/Moments
		public async Task DenyFriendship (User friend)
		{
			PendingFriends.Remove (friend);

			using (var handler = new ZumoAuthHeaderHandler ()) {
				using (var client = MobileServiceClientFactory.CreateClient (handler)) {
					var existingFriendshipList = await client.GetTable<Friendship> ()
						.Where (friendship => friendship.UserId == friend.Id)
						.Where (friendship => friendship.FriendId == AccountService.Instance.Account.UserId).ToListAsync ();

					var existingFriendship = existingFriendshipList [0];
					await client.GetTable<Friendship> ().DeleteAsync (existingFriendship);
				}
			}
		}
コード例 #4
0
ファイル: FriendService.cs プロジェクト: pabalexa/Moments
		public async Task<bool> AcceptFriendship (User friend)
		{
			PendingFriends.Remove (friend);
			Friends.Add (friend);

			using (var handler = new ZumoAuthHeaderHandler ()) {
				using (var client = MobileServiceClientFactory.CreateClient (handler)) {
					var existingFriendshipList = await client.GetTable<Friendship> ()
						.Where (friendship => friendship.UserId == friend.Id)
						.Where (friendship => friendship.FriendId == AccountService.Instance.Account.UserId).Select (user => user.Id).ToListAsync ();

					if (existingFriendshipList.Count == 0) {
						return false;
					} else {
						var friendship = await client.GetTable<Friendship> ().LookupAsync (existingFriendshipList [0]);
						friendship.Accepted = true;
						await client.GetTable<Friendship> ().UpdateAsync (friendship);

						return true;
					}
				}
			}
		}
コード例 #5
0
ファイル: SignUpViewModel.cs プロジェクト: pabalexa/Moments
		private async Task CreateAccount (Account account, User user)
		{
			await AccountService.Instance.Register (account, user);
		}