async void Confirm_Clicked(object sender, System.EventArgs e) { Loading.Start(Loader, LoaderBackground); Random ran = new Random(); GreenBank_Transaction transac = new GreenBank_Transaction() { ReferenceNumber = "BT" + ran.Next(0, 100000000), Amount = Convert.ToInt32(amount), Sender = App.User.ID, Receiver = Convert.ToInt32(App.Check ? App.FavoruSelected.ID : cardSelected.ID), SenderAccount = user.AccountNumber, SenderCountryCode = App.User.CountryCode, ReceiverAccount = App.Check ? App.FavoruSelected.AccountNumber : cardSelected.AccountNumber, TransactionType = 2, SenderMobileNumber = App.User.MobileNo, ReceiverMobileNumber = App.User.MobileNo, TransactionDateTime = DateTime.Now, Note = note }; bool result = await Services.InsertTransaction(transac); if (!result) { await DisplayAlert("Something Wrong", "Can't Transfer", "OK"); Loading.Stop(Loader, LoaderBackground); return; } bool Succeed = await Services.MinusAccountBalance(App.User.ID, user.AccountNumber, Convert.ToInt32(amount)); if (!Succeed) { await DisplayAlert("Something Wrong", "Can't Transfer", "OK"); Loading.Stop(Loader, LoaderBackground); return; } Loading.Stop(Loader, LoaderBackground); await Navigation.PushAsync(new PayBills2.TransferSuccessfulPage(user, cardSelected, amount)); }
async public static Task <bool> InsertTransaction(GreenBank_Transaction GBtransaction) { String jsonContent = JsonConvert.SerializeObject(GBtransaction); var content = new StringContent(jsonContent, Encoding.UTF8, "application/json"); var response = await Client.PostAsync(InsertTransactionURI, content); if (response != null) { var responseString = await response.Content.ReadAsStringAsync(); BoolStatusMessageSimpleResponse data = JsonConvert.DeserializeObject <BoolStatusMessageSimpleResponse>(responseString); if (data.Status == false) { Console.WriteLine(data.Message); return(false); } return(true); } return(false); }