Пример #1
0
        public async Task <eMailStatus> SendEmailInfoAsync(eMail mail)
        {
            //string uri = Constants.RestUrl.ToString();
            var uri = new Uri(string.Format(Constants.RestUrl));

            try
            {
                var json    = JsonConvert.SerializeObject(mail);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                HttpResponseMessage response = null;

                response = await client.PostAsync(uri, content);


                if (response.IsSuccessStatusCode)
                {
                    eMailStatus outStat = new eMailStatus();
                    outStat.statusCode = response.StatusCode.ToString();


                    Debug.WriteLine(@"				email successfully sent successfully saved.");
                    return(outStat);
                }
                else
                {
                    eMailStatus outStat = new eMailStatus();
                    outStat.statusCode = response.StatusCode.ToString();


                    return(outStat);
                }
            }
            catch (Exception ex)
            {
                eMailStatus outStat = new eMailStatus();
                outStat.statusCode = "500";
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
                return(outStat);
            }
        }
Пример #2
0
        async void OnSaveActivated(object sender, EventArgs e)
        {
            //var EmailTest = (eMail)BindingContext;
            eMail       EmailTest = new eMail();
            eMailStatus EmailStat = new eMailStatus();

            EmailTest.emailAddress = emailEntry.Text;
            try
            {
                EmailStat = await App.BuildManager.SendEmailAsync(EmailTest);

                if (EmailStat.statusCode.ToString() == "200")
                {
                    emailEntry.Text = "Email Successfully Sent";
                }
                if (EmailStat.statusCode.ToString() == "404")
                {
                    emailEntry.Text = "Email Address Not Found - Must be in our database to continue - check entry";
                }
                if (EmailStat.statusCode.ToString() == "500")
                {
                    emailEntry.Text = "Issue sending email - please try again later";
                }


                //enterButton.IsVisible = false;
                //confirmButton.IsVisible = true;
                //confirmEntry.IsVisible = true;
                //emailEntry.IsVisible = false;



                new NavigationPage(new StartPage());
            }
            catch
            {  }

            //await Navigation.PopToRootAsync();
        }