private async Task BtnPickAvatarCommandAsync() { BtnPickAvatarIsEnable = false; SJFileStream stream = await DependencyService.Get <IFilePicker>().GetImageStreamAsync(); BtnPickAvatarIsEnable = true; if (stream != null) { var pop = await _dialogService.OpenLoadingPopup(); var obj = await _candidateDetailsService.AddEditContactAvatarImage(stream); if (obj != null) { try { if (obj["Success"] == "true") //success { CandidateMainViewModel.Current.AvatarUrl = RequestService.HOST_NAME + "api/Document/GetContactImage?id=" + obj["Result"]; AvatarUrl = RequestService.HOST_NAME + "api/Document/GetContactImage?id=" + obj["Result"]; (CandidateMainViewModel.Current.ProfilePage as CandidateProfileViewModel).Profile.AvatarUrl = AvatarUrl; await _dialogService.PopupMessage("Update Cover image Successefully", "#52CD9F", "#FFFFFF"); } else if (obj["Success"] == "false") { await _dialogService.PopupMessage("Haven't image file, please try again!!", "#CF6069", "#FFFFFF"); } } catch { await _dialogService.PopupMessage("An error has occurred, please try again!!", "#CF6069", "#FFFFFF"); await _dialogService.CloseLoadingPopup(pop); } } await _dialogService.CloseLoadingPopup(pop); } }
private async Task SubmitRegisterAsync() { var pop = await _dialogService.OpenLoadingPopup(); Register reg = new Register { FirstName = _fieldFirstName, LastName = _fieldLastName, Email = _fieldEmail, Password = _fieldPassword, UserName = _fieldEmail, ConfirmPassword = _fieldPasswordConfirm, AccountName = _fieldCompanyName, Industry = _fieldIndustry }; Dictionary <string, object> obj = await _employerDetailService.EmployerRegister(reg); if (obj != null) { try { if (obj["Success"].ToString() == "true") //success { await _dialogService.PopupMessage("Register Successefully", "#52CD9F", "#FFFFFF"); App.ContactID = obj["ContactID"].ToString(); App.UserName = obj["UserName"].ToString(); App.PassWord = FieldPassword; RequestService.ACCESS_TOKEN = obj["access_token"].ToString(); if (_avatarStream != null) { Dictionary <string, object> objUpload = await _candidateDetailService.AddEditContactAvatarImage(_avatarStream); try { if (objUpload["Success"].ToString() == "true") //success { await _dialogService.PopupMessage("Update Cover image Successefully", "#52CD9F", "#FFFFFF"); } else if (objUpload["Success"].ToString() == "false") { await _dialogService.PopupMessage("Haven't image file, please try again!!", "#CF6069", "#FFFFFF"); } } catch { await _dialogService.PopupMessage("An error has occurred, please try again!!", "#CF6069", "#FFFFFF"); await _dialogService.CloseLoadingPopup(pop); } finally { await PopupNavigation.Instance.PopAllAsync(); await NavigationService.NavigateToAsync <LoginViewModel>(); } } else { await PopupNavigation.Instance.PopAllAsync(); await NavigationService.NavigateToAsync <LoginViewModel>(); } } else if (obj["Message"].ToString() == "IsExists") //is exists { await _dialogService.PopupMessage("This account is exists!", "#CF6069", "#FFFFFF"); } else if (obj["Message"].ToString() == "TryAgaint") //fail { await _dialogService.PopupMessage("An error has occurred, please try again!", "#CF6069", "#FFFFFF"); } } catch { await _dialogService.PopupMessage("An error has occurred, please try again!", "#CF6069", "#FFFFFF"); } } await _dialogService.CloseLoadingPopup(pop); }