Exemplo n.º 1
0
        private void PageMethodsWebFormsUpdate()
        {
            if (lstPageMethodsWebForms.SelectedItems.Count != 1)
            {
                MessageBox.Show("Please select one item in the list.", "PageMethods WebForms - Update");
                return;
            }

            int theId = 0;

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

                GetFooByIdResponse response = fooSvc.GetById(new FooByIdParameters { id = theId });
                Foo foo = response.D;

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

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

                    fooSvc.Update(new UpdateParameters { id = foo.Id, value = foo });
                }
            }
            else
            {
                MessageBox.Show("Invalid Foo.", "PageMethods WebForms - Update");

                lstPageMethodsWebForms.SelectedItems.Clear();
            }

            PageMethodsWebFormsRefresh();
        }