Ejemplo n.º 1
0
        public ActionResult UpdateanApp(OneSignalApplication oneSignalUpdateAppRequest)
        {
            bool Issuccess = _oneSignalAPIService.OneSignalUpdateApp(oneSignalUpdateAppRequest);

            if (Issuccess)
            {
                return(RedirectToAction("AdminIndex"));
            }
            else
            {
                return(View(oneSignalUpdateAppRequest));
            }
        }
        // Get ann App
        public OneSignalApplication OneSignalGetannApp(string id)
        {
            OneSignalApplication oneSignalApplication = null;

            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "YWY4NzkxYzYtODM5Yi00MmY3LTg1ZjgtNmQyYjI1NDdhMmFh");


                var response = client.GetAsync("https://onesignal.com/api/v1/apps/" + id).Result;
                if (response.IsSuccessStatusCode)
                {
                    var stringResult = response.Content.ReadAsStringAsync().Result;
                    oneSignalApplication = JsonConvert.DeserializeObject <OneSignalApplication>(stringResult);
                }
            }

            return(oneSignalApplication);
        }
        // Get All Apps
        public List <OneSignalApplication> OneSignalGetApps(OneSignalApplication oneSignalGetAppsRequest)
        {
            List <OneSignalApplication> MyApps = null;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://onesignal.com");
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "YWY4NzkxYzYtODM5Yi00MmY3LTg1ZjgtNmQyYjI1NDdhMmFh");


                var response = client.GetAsync("/api/v1/apps").Result;
                if (response.IsSuccessStatusCode)
                {
                    var stringResult = response.Content.ReadAsStringAsync().Result;
                    MyApps = JsonConvert.DeserializeObject <List <OneSignalApplication> >(stringResult);
                }
            }
            return(MyApps);
        }
        // Get Update App
        public bool OneSignalUpdateApp(OneSignalApplication oneSignalUpdateAppRequest)
        {
            bool success = false;

            using (HttpClient client = new HttpClient())
            {
                // ////////////// Header
                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", "YWY4NzkxYzYtODM5Yi00MmY3LTg1ZjgtNmQyYjI1NDdhMmFh");
                // //////////////////
                var    json     = JsonConvert.SerializeObject(oneSignalUpdateAppRequest);
                var    content  = new StringContent(json, Encoding.UTF8, "application/json");
                string url      = "https://onesignal.com/api/v1/apps" + "/" + oneSignalUpdateAppRequest.ID;
                var    response = client.PutAsync(url, content).Result;
                if (response.IsSuccessStatusCode)
                {
                    success = true;
                }
            }

            return(success);
        }
Ejemplo n.º 5
0
 public ActionResult GettAllApps(OneSignalApplication getappsrequest)
 {
     return(View(_oneSignalAPIService.OneSignalGetApps(getappsrequest)));
 }