Ejemplo n.º 1
0
        public static bool SetReminder(ClsReminder objParamReminder)
        {
            try
            {
                string sResult = "";
                objParamReminder.ApiKey = "abc-1";
                HttpResponseMessage response = CallApiPostMethod(objParamReminder, "SetReminder");
                if (response.IsSuccessStatusCode)
                {
                    sResult = response.Content.ReadAsStringAsync().Result;
                }

                if (sResult != "true")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
 protected static HttpResponseMessage CallApiPostMethod(ClsReminder objParamReminder, string sMethodName)
 {
     try
     {
         HttpClient client = new HttpClient();
         client.BaseAddress = new Uri("http://apitravelreminder.azurewebsites.net/"); //new Uri("http://localhost:49998/");//
         client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
         StringContent       content  = new StringContent(JsonConvert.SerializeObject(objParamReminder), Encoding.UTF8, "application/json");
         HttpResponseMessage response = client.PostAsync("api/Values/" + sMethodName, content).Result;
         return(response);
     }
     catch (Exception)
     {
         throw;
     }
 }