示例#1
0
        public async void GetCompanies()
        {
            //Views.Busy.SetBusy(true, "Please wait...");
            if (Companies == null)
            {
                Companies = new ObservableCollection <SharedCompany>();
            }
            HttpClient client = new HttpClient();
            string     res    = await client.GetStringAsync(new Uri("http://localhost:51070/api/company?searchString=" + SearchString));

            var list = JsonConvert.DeserializeObject <List <SharedCompany> >(res);

            foreach (var item in list)
            {
                if (!Companies.Contains(item))
                {
                    Companies.Add(item);
                }
            }
            for (int i = Companies.Count - 1; i >= 0; i--)
            {
                if (!list.Contains(Companies[i]))
                {
                    Companies.Remove(Companies[i]);
                }
            }
            RaisePropertyChanged("Companies");
            //Views.Busy.SetBusy(false);
        }