Beispiel #1
0
        public static async Task <String> shareSurvey(string id, MailingRequest request)
        {
            using (HttpClient client = new HttpClient())
            {
                var myContent   = JsonConvert.SerializeObject(request);
                var buffer      = Encoding.UTF8.GetBytes(myContent);
                var byteContent = new ByteArrayContent(buffer);
                byteContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

                using (HttpResponseMessage resonse = await client.PutAsync(BaseUrl + "share/" + id, byteContent))
                {
                    using (HttpContent content = resonse.Content)
                    {
                        string data = await content.ReadAsStringAsync();

                        if (data != null)
                        {
                            Debug.WriteLine(data);
                            return(data);
                        }
                    }
                }
            }
            return(String.Empty);
        }
Beispiel #2
0
 private void buttonShare_Click(object sender, EventArgs e)
 {
     if (items.Count() > 0)
     {
         MailingRequest request = new MailingRequest();
         request.subject      = "Survey Link";
         request.destinations = items.ToList <String>();
         Task.Run(async() => await RestHelper.shareSurvey(hostId, request));
         MessageBox.Show("Survey shared successfuly", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("You must at least add one email adress", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }