Exemplo n.º 1
0
        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();
            }
        }
Exemplo n.º 2
0
 private void AddAppliance(ApplianceViewModel avm)
 {
     avm.ClaimCommand = new RelayCommand(() =>
         OnClaim(avm));
     this.AllAppliances.Add(avm);
     switch (avm.Appliance)
     {
         case ApplianceViewModel.ApplianceType.DRYER:
             this.Dryers.Add(avm);
             break;
         case ApplianceViewModel.ApplianceType.WASHER:
             this.Washers.Add(avm);
             break;
     }
 }