コード例 #1
0
        public static void GetLunchtable(LunchtableCallback callback)
        {
            var b = new BackgroundWorker();

            b.DoWork += (sender, args) =>
            {
                var restClient = new RestClient(SvgroupRestUrl);
                restClient.ExecuteAsync(new RestRequest("/days", Method.GET), (response, handle) =>
                {
                    Lunchtable lunchtable;
                    if (response.StatusCode == System.Net.HttpStatusCode.OK)
                    {
                        //TODO: abfangen, falls menü {} ist
                        lunchtable             = JsonHelper.ParseJson <Lunchtable>(response);
                        lunchtable.LastUpdated = System.DateTime.Today;
                        callback(lunchtable);
                    }
                    else
                    {
                        callback(new Lunchtable()
                        {
                            ErrorMessage = response.StatusDescription
                        });
                    }
                });
            };
            b.RunWorkerAsync();
        }
コード例 #2
0
 public static void GetLunchtable(LunchtableCallback callback)
 {
     var b = new BackgroundWorker();
     b.DoWork += (sender, args) =>
     {
         var restClient = new RestClient(SvgroupRestUrl);
         restClient.ExecuteAsync(new RestRequest("/days", Method.GET), (response, handle) =>
         {
             Lunchtable lunchtable;
             if (response.StatusCode == System.Net.HttpStatusCode.OK)
             {
                 //TODO: abfangen, falls menü {} ist
                 lunchtable = JsonHelper.ParseJson<Lunchtable>(response);
                 lunchtable.LastUpdated = System.DateTime.Today;
                 callback(lunchtable);
             }
             else
             {
                 callback(new Lunchtable(){ErrorMessage=response.StatusDescription});
             }
         });
     };
     b.RunWorkerAsync();
 }