Exemplo n.º 1
0
 public ContactsVM()
 {
     _DB = new ContactsContext();
     soapClient = new SoapService.SoapServiceClient();
     Contacts = new ObservableCollection<Contact>();
     Addresses = new ObservableCollection<Address>();
     Companies = new ObservableCollection<Company>();
     AddressIDs = new ObservableCollection<int>();
     /* Old save command
     SaveCommand = new DelegateCommand(() => {
         _DB.SaveChanges();
     });
      */
     SaveCommand = new DelegateCommand(() => {
         foreach (var x in Contacts) {
             soapClient.AddContact(x);
         }
         soapClient.Save();
     });
     /*old Add Contact
     AddContactCommand = new DelegateCommand(() => {
         ViewingContact = new Contact();
         Contacts.Add(ViewingContact);
         _DB.Contacts.Add(VewingContact);
     });
      */
     AddContactCommand = new DelegateCommand(() => {
         ViewingContact = new Contact();
         Contacts.Add(ViewingContact);
         //soapClient.AddContactAsync(ViewingContact);
     });
     AddCompanyCommand = new DelegateCommand(() => {
         ViewingCompany = new Company();
         Companies.Add(ViewingCompany);
         _DB.Companies.Add(ViewingCompany);
     });
     AddAddressCommand = new DelegateCommand(() => {
         ViewingAddress = new Address();
         Addresses.Add(ViewingAddress);
         _DB.Addresses.Add(ViewingAddress);
     });
     DeleteContactCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     DeleteCompanyCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     DeleteAddressCommand = new DelegateCommand(() => {
         _DB.Contacts.Remove(ViewingContact);
         Contacts.Remove(ViewingContact);
     });
     AddContactMethodCommand = new DelegateCommand(() => {
         var cm = new ContactMethod();
         ViewingContact.ContactMethods.Add(cm);
     });
     init();
 }
Exemplo n.º 2
0
        public ContactsVM()
        {
            _DB        = new ContactsContext();
            soapClient = new SoapService.SoapServiceClient();
            Contacts   = new ObservableCollection <Contact>();
            Addresses  = new ObservableCollection <Address>();
            Companies  = new ObservableCollection <Company>();
            AddressIDs = new ObservableCollection <int>();

            /* Old save command
             * SaveCommand = new DelegateCommand(() => {
             *  _DB.SaveChanges();
             * });
             */
            SaveCommand = new DelegateCommand(() => {
                foreach (var x in Contacts)
                {
                    soapClient.AddContact(x);
                }
                soapClient.Save();
            });

            /*old Add Contact
             * AddContactCommand = new DelegateCommand(() => {
             *  ViewingContact = new Contact();
             *  Contacts.Add(ViewingContact);
             *  _DB.Contacts.Add(VewingContact);
             * });
             */
            AddContactCommand = new DelegateCommand(() => {
                ViewingContact = new Contact();
                Contacts.Add(ViewingContact);
                //soapClient.AddContactAsync(ViewingContact);
            });
            AddCompanyCommand = new DelegateCommand(() => {
                ViewingCompany = new Company();
                Companies.Add(ViewingCompany);
                _DB.Companies.Add(ViewingCompany);
            });
            AddAddressCommand = new DelegateCommand(() => {
                ViewingAddress = new Address();
                Addresses.Add(ViewingAddress);
                _DB.Addresses.Add(ViewingAddress);
            });
            DeleteContactCommand = new DelegateCommand(() => {
                _DB.Contacts.Remove(ViewingContact);
                Contacts.Remove(ViewingContact);
            });
            DeleteCompanyCommand = new DelegateCommand(() => {
                _DB.Contacts.Remove(ViewingContact);
                Contacts.Remove(ViewingContact);
            });
            DeleteAddressCommand = new DelegateCommand(() => {
                _DB.Contacts.Remove(ViewingContact);
                Contacts.Remove(ViewingContact);
            });
            AddContactMethodCommand = new DelegateCommand(() => {
                var cm = new ContactMethod();
                ViewingContact.ContactMethods.Add(cm);
            });
            init();
        }