Ejemplo n.º 1
0
        void AdMessages_TouchUpInside(object sender, EventArgs e)
        {
            Ad ad = new Ad();

            if (sender == Ad1MessageButton)
            {
                ad = DataObject.Ads[2];
            }

            if (sender == Ad2MessageButton)
            {
                ad = DataObject.Ads[1];
            }

            if (sender == Ad3MessageButton)
            {
                ad = DataObject.Ads[0];
            }

            var brokerPhoneNumber = ad.BrokerCellPhone;
            //var brokerPhoneNumber = "5024171595";

            var smsTo = NSUrl.FromString("sms:" + brokerPhoneNumber);

            if (UIApplication.SharedApplication.CanOpenUrl(smsTo))
            {
                //Clay Martin 1/1/18: Change app name to BuyPlane
                string textMessageBody = "Inquiry about " + ad.Name + " from GlobalAir.com BuyPlane Magazine";

                Action successCallBack = async() =>
                {
                    //Send Inquiry
                    var response = await AdInquiryResponse.AdInquiry(int.Parse(ad.ID), string.Empty, string.Empty, brokerPhoneNumber, string.Empty
                                                                     , ad.BrokerId, AdInquirySource.Text, textMessageBody);

                    if (response.Status != "Success")
                    {
                        HelperMethods.SendBasicAlert("Oops", "There was a problem sending your email to the aircraft broker. Please try again");
                    }
                };

                //try to send text message in the ap
                HelperMethods.ShowAndSendSMS(this, new string[] { brokerPhoneNumber }, textMessageBody, successCallBack);
            }
            else
            {
                var av = new UIAlertView("Not supported",
                                         "Text messaging is not supported on this device",
                                         null,
                                         "OK",
                                         null);
                av.Show();
            }
        }