Exemplo n.º 1
0
        public async Task <int> SaveNewPost(PostFeed newPost)
        {
            if (newPost == null)
            {
                return(0);
            }

            var result = await _postFeedService.SavePostToServer(newPost);

            if (result > 0)
            {
                newPost.PostFeedID   = result;
                newPost.IsSelfPosted = true;

                if (newPost.PosterId == int.Parse(_keyValueCachedUtility.GetUserDefaultsKeyValue("CurrentContactId")))
                {
                    newPost.IsSelfPosted = true;
                }

                try
                {
                    _postFeedRepository.UpdateItem(newPost);
                }
                catch (SQLite.SQLiteException)
                {
                }
            }

            return(result);
        }
        public void SignUpResult(int resultId, bool IsSuccess = true)
        {
            if (IsSuccess && resultId > 0)
            {
                CurrentContact.Id       = resultId;
                CurrentContact.RemoteId = resultId;
                CurrentContact.UserName = CurrentContact.EmailAdd;

                _contactManager.SaveNewDetails(CurrentContact);
                PassingParameters.Add("CurrentContact", CurrentContact);

                string newPage = _keyValueCacheUtility.GetUserDefaultsKeyValue("NewPage");
                _keyValueCacheUtility.RemoveKeyObject("NewPage");

                if (string.IsNullOrEmpty(newPage))
                {
                    ChangeRootAndNavigateToPageHelper(nameof(ViewNames.HomePage), _navigationStackService, _navigationService, PassingParameters);
                }
                else
                {
                    ChangeRootAndNavigateToPageHelper(newPage, _navigationStackService, _navigationService, PassingParameters);
                }

                _keyValueCacheUtility.GetUserDefaultsKeyValue("WasLogin", "true");
                _keyValueCacheUtility.GetUserDefaultsKeyValue("WasSignUpCompleted", "true");
                _keyValueCacheUtility.GetUserDefaultsKeyValue("CurrentContactId", resultId.ToString());
            }

            IsBusy = false;
        }
        public override void PreparingPageBindings()
        {
            _eventAggregator.GetEvent <AddUpdatePostFeedToHubResultCodeEventModel>().Subscribe((message) =>
            {
                IsBusy = false;

                if (message.HttpStatusCode == HttpStatusCode.OK)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        _keyValueCacheUtility.GetUserDefaultsKeyValue("IsForceToGetFromRest", "true");
                        _keyValueCacheUtility.GetUserDefaultsKeyValue("SecondsDelay", "2");
                        await NavigateBackHelper(PassingParameters);
                    });
                }
                else
                {
                    UserDialogs.Instance.Alert(AppStrings.LoadingErrorPostFeed, "Error", "Ok");
                }
            });

            if (PassingParameters != null && PassingParameters.ContainsKey("CurrentContact"))
            {
                CurrentContact = (Contact)PassingParameters["CurrentContact"];
            }

            if (PassingParameters != null && PassingParameters.ContainsKey("SelectedPost"))
            {
                OldPost    = (PostFeed)PassingParameters["SelectedPost"];
                Content    = OldPost.ContentText;
                ButtonText = AppStrings.UpdateText;
            }
            else
            {
                Content    = "";
                ButtonText = AppStrings.PostText;
            }

            if (IsInternetConnected)
            {
                _eventAggregator.GetEvent <LogonPostFeedToHubEventModel>().Publish(new PostFeedMessage {
                    CurrentUser = AppUnityContainer.Instance.Resolve <IServiceMapper>().Instance.Map <Contract.ContactK>(CurrentContact)
                });
            }

            IsBusy = false;
        }
        private async Task SignUpAsync()
        {
            try
            {
                if (ProcessValidationErrors(_validator.Validate(this)))
                {
                    if (ProcessInternetConnection())
                    {
                        var resultId = await _contactManager.SaveDetailsToRemoteDB(CurrentContact);

                        if (resultId > 0)
                        {
                            CurrentContact.Id       = resultId;
                            CurrentContact.RemoteId = resultId;
                            CurrentContact.UserName = CurrentContact.EmailAdd;
                            _contactManager.SaveNewDetails(CurrentContact);
                            PassingParameters.Add(nameof(CurrentContact), CurrentContact);
                            string newPage = _keyValueCacheUtility.GetUserDefaultsKeyValue("NewPage");
                            RemoveCacheKeys();

                            if (string.IsNullOrEmpty(newPage))
                            {
                                await ChangeRootAndNavigateToPageHelper(nameof(Views.MainTabbedPage) + AddPagesInTab());
                            }
                            else
                            {
                                await ChangeRootAndNavigateToPageHelper(newPage, PassingParameters);
                            }

                            AddCacheKeys(resultId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ProcessErrorReportingForRaygun(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        private void GetLogonDetailsFromRemoteDBResult(Entity.Contact clientFromRemote, bool isSuccess = true)
        {
            if (clientFromRemote != null && isSuccess)
            {
                string newPage = _keyValueCacheUtility.GetUserDefaultsKeyValue("NewPage");
                _keyValueCacheUtility.RemoveKeyObject("NewPage");
                _userManager.SaveNewDetails(clientFromRemote);
                _keyValueCacheUtility.GetUserDefaultsKeyValue("Username", clientFromRemote.UserName);
                _keyValueCacheUtility.GetUserDefaultsKeyValue("Password", clientFromRemote.Password);
                _keyValueCacheUtility.GetUserDefaultsKeyValue("WasLogin", "true");
                _keyValueCacheUtility.GetUserDefaultsKeyValue("WasSignUpCompleted", "true");
                _keyValueCacheUtility.GetUserDefaultsKeyValue("CurrentContactId", clientFromRemote.RemoteId.ToString());

                if (string.IsNullOrEmpty(newPage))
                {
                    ChangeRootAndNavigateToPageHelper(nameof(ViewNames.HomePage), _navigationStackService, _navigationService, PassingParameters);
                }
                else
                {
                    ChangeRootAndNavigateToPageHelper(newPage, _navigationStackService, _navigationService, PassingParameters);
                }
            }

            IsBusy = false;
        }
        public override void OnAppearing()
        {
            base.OnAppearing();
            MessagingCenter.Subscribe <HttpResponseMessage <Contract.PostFeedK> >(this, "AddUpdatePostFeedToHubResultCode", message =>
            {
                IsBusy = false;

                if (message.HttpStatusCode == HttpStatusCode.OK)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        _keyValueCacheUtility.GetUserDefaultsKeyValue("IsForceToGetFromRest", "true");
                        _keyValueCacheUtility.GetUserDefaultsKeyValue("SecondsDelay", "2");
                        NavigateBackHelper(_navigationStackService, _navigationService, PassingParameters);
                    });
                }
                else
                {
                    UserDialogs.Instance.Alert(AppStrings.LoadingErrorPostFeed, "Error", "Ok");
                }
            });
        }
        private async Task GoNext()
        {
            ++_instructionIndex;
            IsNotFirstInstruction = true;

            if (_instructionIndex < WelcomeInstructionsData.Instructions.Count())
            {
                InstructionContent = WelcomeInstructionsData.Instructions.Skip(_instructionIndex).Take(1).FirstOrDefault();
            }
            else
            {
                _keyValueCacheUtility.GetUserDefaultsKeyValue("WasWelcomeInstructionLoaded", "true");
                await ChangeRootAndNavigateToPageHelper(nameof(ViewNames.WikiPage), PassingParameters);
            }
        }
Exemplo n.º 8
0
        private async Task NavigateSuccess(Entity.Contact clientFromRemote)
        {
            if (clientFromRemote != null)
            {
                string newPage = _keyValueCacheUtility.GetUserDefaultsKeyValue("NewPage");
                _keyValueCacheUtility.RemoveKeyObject("NewPage");
                _userManager.SaveNewDetails(clientFromRemote);
                RemoveCacheKeys();
                AddCacheKeys(clientFromRemote);

                if (string.IsNullOrEmpty(newPage))
                {
                    await ChangeRootAndNavigateToPageHelper(nameof(MainTabbedPage) + AddPagesInTab());
                }
                else
                {
                    await ChangeRootAndNavigateToPageHelper(newPage);
                }
            }

            IsBusy = false;
        }
 private void GoBack()
 {
     _keyValueCacheUtility.GetUserDefaultsKeyValue("IsForceToGetToLocal", "true");
     _keyboardHelper.HideKeyboard();
     NavigateBackHelper(_navigationStackService, _navigationService, PassingParameters);
 }
Exemplo n.º 10
0
 private async void GoBack()
 {
     _keyValueCacheUtility.GetUserDefaultsKeyValue("IsForceToGetToLocal", "true");
     _keyboardHelper.HideKeyboard();
     await NavigateBackHelper(PassingParameters);
 }