private void TransferBtn_Click(object sender, RoutedEventArgs e)
        {
            RequestHandle handler = new RequestHandle();
            string amount2 = AmountTxt.Text;
            string phone = RecipientPhoneTxt.Text;
            TransferSend trans = new TransferSend() { senderId = p.id, amount = amount2, recipientPhone = phone };
            TransferResponse res = Task.Run(() => handler.transfer(trans)).Result;
            switch (res.responseStatus.status)
            {
                case "SUCCESS":
                    //Route to success page
                    this.Frame.Navigate(typeof(TransferResultPage), new List<Object>() { p ,res.transfer });
                    break;
                case "INVALID_PHONE_FORMAT":
                    AmountErrorTxt.Text = "Phone is not correct!";
                    break;
                default:

                    break;
            }
        }
Beispiel #2
0
        public async Task<TransferResponse> transfer(TransferSend trans)
        {
            try
            {
                var content = new StringContent("{\"senderId\" : \""+trans.senderId+"\",\"recipientPhoneNum\" : \""+trans.recipientPhone+"\",\"amount\" : \""+trans.amount+"\"}", System.Text.Encoding.UTF8, "application/json");


                var response = await httpClient.PostAsync("makeTransfer", content);



                string responseData = await response.Content.ReadAsStringAsync();



                var check = JsonConvert.DeserializeObject<TransferResponse>(responseData);

                return check;
            }
            catch (Exception ex)
            {
                return JsonConvert.DeserializeObject<TransferResponse>("");
            }
            
        }