Beispiel #1
0
        private void RestWcfDelete()
        {
            if (lstRestWcf.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select one item in the list.", "REST Wcf - Delete");
                return;
            }

            int theId = 0;

            if (int.TryParse((string)lstRestWcf.SelectedItems[0].Tag, out theId))
            {
                ProxyConfiguration config = new ProxyConfiguration("http://localhost:59877");
                IFooRestWcf fooSvc = SimpleProxy.Proxy.For<IFooRestWcf>(config);

                fooSvc.Delete(theId);
            }
            else
            {
                MessageBox.Show("Invalid Foo.", "REST Wcf - Delete");

                lstRestWcf.SelectedItems.Clear();
            }

            RestWcfRefresh();
        }
Beispiel #2
0
        private void RestWcfUpdate()
        {
            if (lstRestWcf.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select one item in the list.", "REST Wcf - Update");
                return;
            }

            int theId = 0;

            if (int.TryParse((string)lstRestWcf.SelectedItems[0].Tag, out theId))
            {
                ProxyConfiguration config = new ProxyConfiguration("http://localhost:59877");
                IFooRestWcf fooSvc = SimpleProxy.Proxy.For<IFooRestWcf>(config);

                Foo foo = fooSvc.GetById(theId);

                string theBar = BarDialog.ShowDialog(foo.Bar);

                if (null != theBar)
                {
                    foo.Bar = theBar;

                    fooSvc.Update(foo.Id, foo);
                }
            }
            else
            {
                MessageBox.Show("Invalid Foo.", "REST Wcf - Update");

                lstRestWcf.SelectedItems.Clear();
            }

            RestWcfRefresh();
        }
Beispiel #3
0
        private void RestWcfAdd()
        {
            string bar = BarDialog.ShowDialog(string.Empty);

            ProxyConfiguration config = new ProxyConfiguration("http://localhost:59877");
            IFooRestWcf fooSvc = SimpleProxy.Proxy.For<IFooRestWcf>(config);

            fooSvc.Add(new Foo { Bar = bar });

            RestWcfRefresh();
        }
Beispiel #4
0
        private void RestWcfRefresh()
        {
            ProxyConfiguration config = new ProxyConfiguration("http://localhost:59877");
            IFooRestWcf fooSvc = SimpleProxy.Proxy.For<IFooRestWcf>(config);

            IEnumerable<Foo> foos = fooSvc.FindAll();

            lstRestWcf.Items.Clear();

            foreach (Foo foo in foos)
            {
                lstRestWcf.Items.Add(foo.ToListViewItem());
            }
        }