Beispiel #1
0
        public async Task ApiCallAsync(Integratie2018Context context)
        {
            try
            {
                client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")
                {
                    CharSet = "utf-8"
                });
                StringContent content = new StringContent("{" + GetSince() + "}", System.Text.Encoding.UTF8, "application/json");
                Latest = DateTime.Now;
                context.Entry(this).State = EntityState.Modified;
                context.SaveChanges();
                content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json")
                {
                    CharSet = "utf-8"
                };
                content.Headers.Add("X-API-Key", "aEN3K6VJPEoh3sMp9ZVA73kkr");
                HttpResponseMessage response = await client.PostAsync("http://kdg.textgain.com/query", content);

                string responseString = await response.Content.ReadAsStringAsync();

                responseString.ToString();
                AddBerichten(responseString, context);
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Beispiel #2
0
        public IEnumerable <Bericht> AddBerichten(string json, Integratie2018Context context)
        {
            json = "{ \"berichten\": " + json + " }";
            json = json.Replace("\"geo\": false", "\"geo\": [0, 0]");
            json = json.Replace("\"geo\": [null, null]", "\"geo\": [0, 0]");

            BerichtenClass BerichtenJson;

            try
            {
                BerichtenJson = JsonConvert.DeserializeObject <BerichtenClass>(json);
            }
            catch (Exception e)
            {
                e.ToString();
                BerichtenJson = null;
            }

            BerichtenJson.ToString();

            context.Berichten.AddRange(BerichtenJson.berichten);

            try
            {
                context.SaveChanges();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(BerichtenJson.berichten);
        }
 public FYIRepository()
 {
     ctx = new Integratie2018Context();
 }
 public GebruikerRepository()
 {
     ctx = new Integratie2018Context();
 }
Beispiel #5
0
 public AlertRepository()
 {
     ctx = new Integratie2018Context();
 }
 public GrafiekRepository()
 {
     ctx = new Integratie2018Context();
 }
 public BerichtRepository()
 {
     ctx = new Integratie2018Context();
 }