private async Task SendToServer()
        {
            if (this.userProfile == null)
            {
                return;
            }

            IsBusy = true;
            var userIdentity = userIdentityRepository.GetUserIdentity();
            var response     = await userService.UpdateUserProfile(this.userProfile, userIdentity?.LocalId);

            if (response)
            {
                var profileData = userProfileRepository.GetUserProfile(this.userProfile.Email);
                if (profileData != null)
                {
                    profileData.Category    = this.userProfile.Category;
                    profileData.City        = this.userProfile.City;
                    profileData.CompanyName = this.userProfile.CompanyName;
                    profileData.CompanyRegisteredAddress = this.userProfile.CompanyRegisteredAddress;
                    profileData.Country            = this.userProfile.Country;
                    profileData.Email              = this.userProfile.Email;
                    profileData.IsContractor       = this.userProfile.IsContractor;
                    profileData.Mobile             = this.userProfile.Mobile;
                    profileData.Name               = this.userProfile.Name;
                    profileData.PathToProfileImage = this.userProfile.PathToProfileImage;
                }

                var rowUpdated = userProfileRepository.CreateOrUpdate(profileData);

                if (rowUpdated < 0)
                {
                    Navigator.Instance.OkAlert("Error", "There is a problem storing user profile locally. Please try again later.", "OK", null, null);
                    IsBusy = false;
                    return;
                }


                //this.parentViewModel.UpdateUserProfile(this.userProfile);

                Navigator.Instance.OkAlert("Alert", "User profile is successfully updated.", "OK", async() => {
                    //For android
                    await Navigator.Instance.ReturnPrevious(UIPageType.PAGE);
                    base.NotifyCompletion(this, new EventArgs.ObserverEventArgs(Constants.USER_PROFILE_UPDATE, Constants.CONTRACTOR, this.UserProfile));
                    IsBusy = false;
                }, async() =>
                {
                    //For ios
                    await Navigator.Instance.ReturnPrevious(UIPageType.PAGE);
                    base.NotifyCompletion(this, new EventArgs.ObserverEventArgs(Constants.USER_PROFILE_UPDATE, Constants.CONTRACTOR, this.UserProfile));
                    IsBusy = false;
                });
                return;
            }

            Navigator.Instance.OkAlert("Error", "There is a problem updating user profile on the server. Please try again later.", "OK", null, null);
            IsBusy = false;
        }
Beispiel #2
0
 /// <summary>
 ///     Gets the users identity.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns>Task{UserIdentity}.</returns>
 public Task <UserIdentity> GetUserIdentity(string id)
 {
     return(_identityRepository.GetUserIdentity(id));
 }