private void OnClaim(ApplianceViewModel avm) { if (NetworkInterface.GetIsNetworkAvailable()) { UriBuilder fullUri = new UriBuilder(appSettings.CurrentAPIServer + "/receive.json"); fullUri.Query = String.Format("key={0}&id={1}&name={2}&email={3}&send_email={4}", Uri.EscapeDataString(appSettings.CurrentAPIKey), avm.Id, Uri.EscapeDataString(appSettings.FirstNameSetting), Uri.EscapeDataString(appSettings.EmailAddressSetting), appSettings.SendEmailSetting); // initialize a new WebRequest HttpWebRequest lndrRequest = (HttpWebRequest)WebRequest.Create(fullUri.Uri); // set up the state object for the async request LndrUpdateState lndrUpdateState = new LndrUpdateState(); lndrUpdateState.AsyncRequest = lndrRequest; // start the asynchronous request lndrRequest.BeginGetResponse(new AsyncCallback(HandleUpdateResponse), lndrUpdateState); } else { LoadData(); } }
/// <summary> /// Creates and adds a few ItemViewModel objects into the Items collection. /// </summary> public void LoadData() { // Sample data; replace with real data //AddAppliance(new ApplianceViewModel() { Appliance = ApplianceViewModel.ApplianceType.WASHER, Id = 1, Name = "Washer 1", Busy = false, FreeAt = DateTime.Now }); //AddAppliance(new ApplianceViewModel() { Appliance = ApplianceViewModel.ApplianceType.WASHER, Id = 2, Name = "Washer 2", Busy = true, FreeAt = DateTime.Now.AddHours(1.2) }); //AddAppliance(new ApplianceViewModel() { Appliance = ApplianceViewModel.ApplianceType.DRYER, Id = 3, Name = "Dryer 1", Busy = true, FreeAt = DateTime.Now.AddMinutes(42) }); //AddAppliance(new ApplianceViewModel() { Appliance = ApplianceViewModel.ApplianceType.DRYER, Id = 4, Name = "Dryer 2", Busy = false, FreeAt = DateTime.Now }); this.IsDataLoaded = false; Clear(); if (NetworkInterface.GetIsNetworkAvailable()) { UriBuilder fullUri = new UriBuilder(appSettings.CurrentAPIServer + "/" + Resources.ServerStatusEndpoint); fullUri.Query = String.Format("key={0}", Uri.EscapeDataString(appSettings.CurrentAPIKey)); // initialize a new WebRequest HttpWebRequest lndrRequest = (HttpWebRequest)WebRequest.Create(fullUri.Uri); // set up the state object for the async request LndrUpdateState lndrUpdateState = new LndrUpdateState(); lndrUpdateState.AsyncRequest = lndrRequest; // start the asynchronous request lndrRequest.BeginGetResponse(new AsyncCallback(HandleIndexResponse), lndrUpdateState); } else { this.IsDataLoaded = true; } }