Пример #1
0
        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;
        }
Пример #2
0
        private async Task ExecuteSignInUserCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DialogService.ShowLoading(Strings.SigningIn);
                if (await ConnectivityService.IsConnected())
                {
                    var result = await SignIn();

                    DialogService.HideLoading();

                    if (result)
                    {
                        NavigateToMainUI();
                    }
                    else
                    {
                        DialogService.ShowError(Strings.InvalidCredentials);
                    }
                }
                else
                {
                    DialogService.ShowError(Strings.NoInternetConnection);
                }
            }
            catch (Exception ex)
            {
                Xamarin.Insights.Report(ex);
            }

            IsBusy = false;
        }
Пример #3
0
        public async Task ExecuteSendMomentCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DialogService.ShowLoading(Strings.SendingMoment);
                if (await ConnectivityService.IsConnected())
                {
                    var success = await SendImage();

                    DialogService.HideLoading();
                    if (success)
                    {
                        DialogService.ShowSuccess(Strings.MomentSent, 1);
                        await page.Navigation.PopModalAsync();
                    }
                    else
                    {
                        DialogService.ShowError(Strings.ErrorOcurred);
                    }
                }
                else
                {
                    DialogService.ShowError(Strings.NoInternetConnection);
                }
            }
            catch (Exception ex)
            {
                Xamarin.Insights.Report(ex);
            }

            IsBusy = false;
        }
Пример #4
0
        private async Task ExecuteAddFriendCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                DialogService.ShowLoading(Strings.AddingFriend);
                if (await ConnectivityService.IsConnected())
                {
                    var success = await CreateFriendship();

                    DialogService.HideLoading();
                    if (success)
                    {
                        DialogService.ShowSuccess(Strings.FriendAdded);
                    }
                    else
                    {
                        DialogService.ShowError(Strings.FriendRequestFailed);
                    }
                }
                else
                {
                    DialogService.ShowError(Strings.NoInternetConnection);
                }
            }
            catch (Exception ex)
            {
                Xamarin.Insights.Report(ex);
            }

            IsBusy = false;
        }