public async Task GetProfile() { var response = await mApiService.GetProfile(); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { mUserProfile = response.Data; DataHelper.SaveToUserPref(mUserProfile, "UserProfile"); mCacheService.UserProfileItem = mUserProfile; if (mUserProfile.PersonalProfile.ProfileCompletionStep == ProfileCompletionStep.PPComplete) { mCacheService.IsShowProfileView = true; } else { mCacheService.IsShowProfileView = false; } } else { if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); Debug.WriteLine("Error" + err.Description); mMessageboxService.ShowToast(err.Description); } } }
public async void LoadInviteeProfile(int inviteeUserId) { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var response = await mApiService.GetInviteeProfile(inviteeUserId); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { UserProfile = response.Data; CheckCertForUpdateUI(UserProfile); if (UserProfile.PersonalProfile != null) { ConstructionCardItem.CertItem = UserProfile.PersonalProfile.Certs[0]; TraceLicenseItem.CertItem = UserProfile.PersonalProfile.Certs[1]; IncomeInsured.CertItem = UserProfile.PersonalProfile.Certs[2]; FirstAidCertified.CertItem = UserProfile.PersonalProfile.Certs[3]; GSTRegistered.CertItem = UserProfile.PersonalProfile.Certs[4]; PerPublicLiabilityCert.CertItem = UserProfile.PersonalProfile.Certs[UserProfile.PersonalProfile.Certs.Count - 1]; } //company profile if (UserProfile.CompanyProfile != null) { CompensationCert.CertItem = UserProfile.CompanyProfile.Certs[0]; PublicLiabilityCert.CertItem = UserProfile.CompanyProfile.Certs[1]; ProductLiabilityCert.CertItem = UserProfile.CompanyProfile.Certs[2]; GSTRegistered.CertItem = UserProfile.CompanyProfile.Certs[3]; } View.HidenAddCompanyDetails(); } else { if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); Debug.WriteLine("Error" + err.Description); mMessageboxService.ShowToast(err.Description); } } }
private async void Save() { try { CertValidator validatorWorkCompenstation = new CertValidator(); var result3 = validatorWorkCompenstation.Validate(CompensationCert); if (!result3.IsValid) { var firstError = result3.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } CertValidator validatorPublicLiability = new CertValidator(); var result = validatorPublicLiability.Validate(PublicLiabilityCert); if (!result.IsValid) { var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } CertValidator validatorProductLiability = new CertValidator(); var result1 = validatorProductLiability.Validate(ProductLiabilityCert); if (!result1.IsValid) { var firstError = result1.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } for (int j = 0; j < LicenceCerts.Count; j++) { CertValidator validatorLicences2 = new CertValidator(); var result2 = validatorLicences2.Validate(LicenceCerts[j]); if (!result2.IsValid) { var firstError = result2.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } } if (IsCheckVerify == false) { mMessageboxService.ShowToast("Please verify this is information is true "); View.ScrollToBottom(); return; } if (IsTickPublicLiability != true) { PublicLiabilityCert.CertItem.Amount = null; PublicLiabilityCert.CertItem.Document = null; PublicLiabilityCert.CertItem.Expiry = null; } if (IsTickProductLiability != true) { ProductLiabilityCert.CertItem.Amount = null; ProductLiabilityCert.CertItem.Document = null; ProductLiabilityCert.CertItem.Expiry = null; } if (IsTickCompensation != true) { CompensationCert.CertItem.Document = null; CompensationCert.CertItem.Expiry = null; } mCompanyProfile.Certs[0] = CompensationCert.CertItem; mCompanyProfile.Certs[1] = PublicLiabilityCert.CertItem; mCompanyProfile.Certs[2] = ProductLiabilityCert.CertItem; mCompanyProfile.Certs[3] = GSTRegisteredCert.CertItem; for (int i = 0; i < LicenceCerts.Count; i++) { mCompanyProfile.Certs.Add(LicenceCerts[i].CertItem); } mCompanyProfile.ProfileCompletionStep = ProfileCompletionStep.CPComplete; mCompanyProfile.StatementAgree = DateTime.Now; mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); while (!Mvx.Resolve <ITaskManagementService>().IsAllTaskDone()) { int numOfImages = Mvx.Resolve <ITaskManagementService>().NumberOfTasksRunning(); if (numOfImages > 0) { string uploadStr = numOfImages + (numOfImages > 1 ? " images " : " image ") + "processing"; mProgressDialogService.ShowProgressDialog(uploadStr); } else { mProgressDialogService.ShowProgressDialog(""); } await Task.Delay(150); } var response = await mApiService.CreateCompanyProfile(mCompanyProfile); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { mCacheService.IsShowProfileView = true; mMessageboxService.ShowToast("Company Profile Complete"); Mvx.Resolve <ITrackingService>().SendEvent("Company Profile completed"); ViewModelAction action = new ViewModelAction { ActionType = ViewModelActionType.Reload, ViewModelType = typeof(ProfileViewModel), Data = "COMPLETED_PROFILE" }; Mvx.Resolve <IMvxMessenger>().Publish(new ViewModelActionMessage(this, action)); BackToViewModel <MainViewModel>(); } else { RefreshListLicences(); if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); mMessageboxService.ShowToast(err.Description); } } } catch (Exception ex) { RefreshListLicences(); mMessageboxService.Show("Error", ex.Message); } }
private async void SignIn() { if (View != null) { View.HideKeyboard(); } LoginValidator validator = new LoginValidator(); Login login = new Login { Email = Email, Password = Password, }; var result = validator.Validate(login); if (result.IsValid) { mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); var response = await mApiService.PostLogin(login.Email, login.Password); if (response.StatusCode == System.Net.HttpStatusCode.OK) { var userData = response.Data; mCacheService.CurrentUserData = userData; mApiService.UseBeaerToken = true; // get user key //mPlatformService.ShowNetworkIndicator(); //mProgressDialogService.ShowProgressDialog(); var response2 = await mApiService.PostSession(mPlatformService.GetDeviceUDID(), userData.UserName); //mPlatformService.HideNetworkIndicator(); //mProgressDialogService.HideProgressDialog(); if (response2.StatusCode == System.Net.HttpStatusCode.OK) { userData.UserKey = response2.Data; mCacheService.CurrentUserData = userData; await GetProfile(); ShowViewModel <MainViewModel>(); } else { mApiService.UseBeaerToken = false; } } else { mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); mMessageboxService.ShowToast(err.Description); } } } else if (result.Errors != null) { var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); } }
private async void ShowNext() { try { View.HideKeyboard(); if (CurrentPage < 5) { CurrentPage += 1; } var personalProfileTemp = DataHelper.RetrieveFromUserPref <PersonalProfile>("PERSONAL_STEP"); if (personalProfileTemp != null) { mPersonalProfileLocal = personalProfileTemp; } if (CurrentPage == 2) { mPersonalProfileLocal.FirstName = FirstName; mPersonalProfileLocal.LastName = LastName; mPersonalProfileLocal.DOB = DOB; mPersonalProfileLocal.Mobile = MobileNumber; mPersonalProfileLocal.BulidingNo = UnitNumber; mPersonalProfileLocal.Street = StreetName; mPersonalProfileLocal.PostCode = PostCode; mPersonalProfileLocal.State = State; mPersonalProfileLocal.NOK = NOK; mPersonalProfileLocal.NOKPhone = NOKPhone; PersonalProfileValidator validatorPersonalProfile = new PersonalProfileValidator(); var result = validatorPersonalProfile.Validate(mPersonalProfileLocal); if (!result.IsValid) { CurrentPage -= 1; var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } View.PanToPage(CurrentPage); HightlightStep(true, true, false, false); if (personalProfileTemp != null) { mPersonalProfileLocal.ProfileCompletionStep = personalProfileTemp.ProfileCompletionStep; } else { mPersonalProfileLocal.ProfileCompletionStep = ProfileCompletionStep.PPStep1; } } else if (CurrentPage == 3) { CertValidator validatorConstructionCard = new CertValidator(); var result = validatorConstructionCard.Validate(ConstructionCardItem); if (!result.IsValid) { CurrentPage -= 1; var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } View.PanToPage(CurrentPage); HightlightStep(true, true, true, false); if (personalProfileTemp != null) { if (personalProfileTemp.Certs.Count > 0) { mPersonalProfileLocal.ProfileCompletionStep = personalProfileTemp.ProfileCompletionStep; mPersonalProfileLocal.Certs[0] = ConstructionCardItem.CertItem; } else { mPersonalProfileLocal.ProfileCompletionStep = ProfileCompletionStep.PPStep2; mPersonalProfileLocal.Certs.Add(ConstructionCardItem.CertItem); } } else { mPersonalProfileLocal.ProfileCompletionStep = ProfileCompletionStep.PPStep2; mPersonalProfileLocal.Certs.Add(ConstructionCardItem.CertItem); } } else if (CurrentPage == 4) { CertValidator validatorTraceLicense = new CertValidator(); var result = validatorTraceLicense.Validate(TraceLicenseItem); if (!result.IsValid) { CurrentPage -= 1; var firstError = result.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } View.PanToPage(CurrentPage); HightlightStep(true, true, true, true); if (personalProfileTemp != null) { if (personalProfileTemp.Certs.Count > 1) { mPersonalProfileLocal.ProfileCompletionStep = personalProfileTemp.ProfileCompletionStep; mPersonalProfileLocal.Certs[1] = TraceLicenseItem.CertItem; } else { mPersonalProfileLocal.ProfileCompletionStep = ProfileCompletionStep.PPStep3; mPersonalProfileLocal.Certs.Add(TraceLicenseItem.CertItem); } } else { mPersonalProfileLocal.ProfileCompletionStep = ProfileCompletionStep.PPStep3; mPersonalProfileLocal.Certs.Add(TraceLicenseItem.CertItem); } } DataHelper.SaveToUserPref(mPersonalProfileLocal, "PERSONAL_STEP"); if (CurrentPage == 5) // Done button { CertValidator validatorIncomeInsuredCert = new CertValidator(); var result4 = validatorIncomeInsuredCert.Validate(IncomeInsured); if (!result4.IsValid) { var firstError = result4.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } CertValidator validatorFirstAidCert = new CertValidator(); var result5 = validatorFirstAidCert.Validate(FirstAidCertified); if (!result5.IsValid) { var firstError = result5.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } for (int i = 0; i < OperationalCerts.Count; i++) { CertValidator validatorOperationalCert = new CertValidator(); var result3 = validatorOperationalCert.Validate(OperationalCerts[i]); if (!result3.IsValid) { var firstError = result3.Errors.First(); mMessageboxService.ShowToast(firstError.ErrorMessage); return; } } if (IsVerify == false) { mMessageboxService.ShowToast("Please verify this information is true"); View.ScrollToBottom(); return; } mPlatformService.ShowNetworkIndicator(); mProgressDialogService.ShowProgressDialog(); while (!Mvx.Resolve <ITaskManagementService>().IsAllTaskDone()) { int numOfImages = Mvx.Resolve <ITaskManagementService>().NumberOfTasksRunning(); if (numOfImages > 0) { string uploadStr = numOfImages + (numOfImages > 1 ? " images " : " image ") + "processing"; mProgressDialogService.ShowProgressDialog(uploadStr); } else { mProgressDialogService.ShowProgressDialog(""); } await Task.Delay(150); } Debug.WriteLine("upload all image is done"); if (Mvx.Resolve <ITaskManagementService>().IsAllTaskDone()) { UserProfile.PersonalProfile.FirstName = FirstName; UserProfile.PersonalProfile.LastName = LastName; UserProfile.PersonalProfile.DOB = DOB; UserProfile.PersonalProfile.Mobile = MobileNumber; UserProfile.PersonalProfile.BulidingNo = UnitNumber; UserProfile.PersonalProfile.Street = StreetName; UserProfile.PersonalProfile.State = State; UserProfile.PersonalProfile.NOK = NOK; UserProfile.PersonalProfile.NOKPhone = NOKPhone; UserProfile.PersonalProfile.PostCode = PostCode; if (IsTickFirstAid != true) { FirstAidCertified.CertItem.Document = null; FirstAidCertified.CertItem.Expiry = null; } if (IsTickIncomeInsured != true) { IncomeInsured.CertItem.Document = null; IncomeInsured.CertItem.Expiry = null; } UserProfile.PersonalProfile.Certs[0] = ConstructionCardItem.CertItem; UserProfile.PersonalProfile.Certs[1] = TraceLicenseItem.CertItem; UserProfile.PersonalProfile.Certs[2] = IncomeInsured.CertItem; UserProfile.PersonalProfile.Certs[3] = FirstAidCertified.CertItem; UserProfile.PersonalProfile.Certs[4] = GSTRegistered.CertItem; UserProfile.PersonalProfile.Certs[6] = PublicLiablityCert.CertItem; for (int k = 0; k < OperationalCerts.Count; k++) { UserProfile.PersonalProfile.Certs.Add(OperationalCerts[k].CertItem); } UserProfile.PersonalProfile.StatementAgree = DateTime.Now; UserProfile.PersonalProfile.ProfileCompletionStep = ProfileCompletionStep.PPComplete; var response = await mApiService.CreatePersonalProfile(UserProfile.PersonalProfile); mPlatformService.HideNetworkIndicator(); mProgressDialogService.HideProgressDialog(); if (response.StatusCode == System.Net.HttpStatusCode.OK) { mCacheService.IsShowProfileView = true; Mvx.Resolve <ITrackingService>().SendEvent("Personal Profile completed"); View.ShowPopupFinish(); } else { RefreshListOperationalCert(); if (!string.IsNullOrEmpty(response.ErrorData)) { string errorData = response.ErrorData; ErrorLoginResponse err = JsonConvert.DeserializeObject <ErrorLoginResponse>(errorData); mMessageboxService.ShowToast(err.Description); } } } } } catch (Exception ex) { #if DEBUG RefreshListOperationalCert(); mMessageboxService.Show("Error", ex.Message); #endif } }