//---start-------------------------------------------------------------------------------------CLICK EVENTS---// private void OnLoginButton(object sender, EventArgs e) { validationError.Text = ""; if (!EmailEmpty() && !PasswordEmpty()) { if (EmailValid()) { var AuthService = DependencyService.Get <IAuthService>(); AuthService.SaveCredentials(emailForm.Text.ToLower().Trim(), StringFormatUtil.ToBase64(passwordForm.Text.Trim())); UserExistCheck(); } } }
public async Task <HostResult> Login(string email, string password) { JObject @params = new JObject() { new JProperty("params", new JObject() { new JProperty("auth", new JObject() { new JProperty("db", "kamooni"), new JProperty("login", email.ToLower().Trim()), new JProperty("password", StringFormatUtil.ToBase64(password)) }) }) }; HostResponse response = await restClient.PostAsync <HostResponse, JObject>(ApiURI.URL_MAIN + ApiURI.URI_SIGN_IN, @params); return(response?.Result); }
private async void SubmitReview() { try { UserDialogs.Instance.Loading(title: "Submiting Review...").Show(); var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(30) }; //var AuthService = DependencyService.Get<IAuthService>(); JObject jsonAuth = new JObject { { "login", Settings.Email }, { "password", StringFormatUtil.ToBase64(Settings.Password) }, { "db", ServerAuth.DB } }; string imageBase64 = ""; if (imagefile != null) { byte[] imageBytes = await StorageHelper.LoadImage(imagefile.Path); imageBase64 = Convert.ToBase64String(imageBytes); } JObject jsonReview = new JObject { { "title", Host.Name }, { "token", Host.Token }, { "text", txtContent.Text?.Trim() ?? "" }, { "image", imageBase64 }, { "rating", rating.Rating }, { "visit_token", "" } }; JObject jsonDataObject = new JObject { { "auth", jsonAuth }, { "review", jsonReview } }; JObject jsonData = new JObject { { "params", jsonDataObject } }; var data = jsonData.ToString(); var content = new StringContent(data, Encoding.UTF8, "application/json"); var response = await client.PostAsync(ApiURI.URL_MAIN + ApiURI.REVIEW_HOST, content); string responseContent = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { ReviewHostResponse successResponse = JsonConvert.DeserializeObject <ReviewHostResponse>(responseContent, App.DefaultSerializerSettings); if (successResponse != null && successResponse.Result != null) { if (successResponse.Result.Success) { ReviewToken = successResponse.Result.ReviewToken; popupShareIns1.IsVisible = true; } else if (!string.IsNullOrWhiteSpace(successResponse.Result.Message)) { UserDialogs.Instance.Toast(new ToastConfig(successResponse.Result.Message)); } } else { Internal.ServerError(); } } else { Internal.ServerError(); } } catch (TaskCanceledException e) { UserDialogs.Instance.Toast(new ToastConfig("Bad Connection Error. Try Again")); Debug.WriteLine(e.Message); } catch (Exception e) { Internal.ServerError(); Debug.WriteLine(e.Message); } finally { UserDialogs.Instance.Loading().Hide(); } }