Exemplo n.º 1
0
        public ContactsVM() {
            var db = new FinalContext();
           
            ContactList = db.People.Local;
            db.People.Load(); 
            EmailList = new ObservableCollection<Email>();
            AddressList = new ObservableCollection<Address>();
            PhoneList = new ObservableCollection<Phone>();
            TypeList = new ObservableCollection<CType>();

            SaveCommand = new DelegateCommand(() => db.SaveChanges());
            AddPersonCommand = new DelegateCommand(() => {
                CurrentPerson = new Person();
                ContactList.Add(CurrentPerson);
                db.People.Add(CurrentPerson);
            });
            AddEmailCommand = new DelegateCommand(() => {
                var em = new Email();
                CurrentPerson.Emails.Add(em);
            });
            DeletePersonCommand = new DelegateCommand(() => {
                db.People.Remove(CurrentPerson);
                ContactList.Remove(CurrentPerson);
            });
            AddPhoneCommand = new DelegateCommand(() => {
                var pn = new Phone();
                CurrentPerson.Phones.Add(pn);
            });
            AddAddressCommand = new DelegateCommand(() => {
                var ad = new Address();
                CurrentPerson.Addresses.Add(ad);
            });
            DeleteAddressCommand = new DelegateCommand(() => {
                db.Addresses.Remove(CurrentAddress);
                AddressList.Remove(CurrentAddress);
            });
            DeletePhoneCommand = new DelegateCommand(() => {
                db.Phones.Remove(CurrentPhone);
                PhoneList.Remove(CurrentPhone);
            });
            DeleteEmailCommand = new DelegateCommand(() => {
                db.Emails.Remove(CurrentEmail);
                EmailList.Remove(CurrentEmail);
            });

        }
Exemplo n.º 2
0
 public void RemoveAddress(Address ad) {
     db.Configuration.ProxyCreationEnabled = false;
     db.Addresses.Remove(ad);
 }
Exemplo n.º 3
0
 public void AddAddress(Address ad) {
    // var db = new FinalContext();
     db.Configuration.ProxyCreationEnabled = false;
     db.Addresses.Add(ad);
 }
Exemplo n.º 4
0
        public ContactsVM() {
            var BubbleClient = new Bubble.ContactsSoapClient();
            //db = new FinalContext();

            //ContactList = db.People.Local;
            //db.People.Load();

            //EmailList = db.Emails.Local;
            //db.Emails.Load();

            //PhoneList = db.Phones.Local;
            //db.Phones.Load();

            //AddressList = db.Addresses.Local;
            //db.Addresses.Load();
            ContactList = new ObservableCollection<Person>();
            EmailList = new ObservableCollection<Email>();
            PhoneList = new ObservableCollection<Phone>();
            AddressList = new ObservableCollection<Address>();
            Init();

            SaveCommand = new DelegateCommand(() => BubbleClient.Save());
            AddPersonCommand = new DelegateCommand(() => {
                CurrentPerson = new Person();
                ContactList.Add(CurrentPerson);
                BubbleClient.AddPersonAsync(CurrentPerson);
            });
            AddEmailCommand = new DelegateCommand(() => {
                var em = new Email();
                em.PersonID = CurrentPerson.PID;
                EmailList.Add(em);
                CurrentPerson.elist.Add(em);
                BubbleClient.AddEmailAsync(em);
            });
            DeletePersonCommand = new DelegateCommand(() => {
                db.People.Remove(CurrentPerson);
                ContactList.Remove(CurrentPerson);
            });
            AddPhoneCommand = new DelegateCommand(() => {
                var pn = new Phone();
                pn.PersonID = CurrentPerson.PID;
                PhoneList.Add(pn);
                CurrentPerson.plist.Add(pn);
                BubbleClient.AddPhoneAsync(pn);
            });
            AddAddressCommand = new DelegateCommand(() => {
                var ad = new Address();
                ad.PersonID = CurrentPerson.PID;
                CurrentPerson.alist.Add(ad);
                AddressList.Add(ad);
                BubbleClient.AddAddressAsync(ad);
            });
            DeleteAddressCommand = new DelegateCommand(() => {
                CurrentPerson.alist.Remove(CurrentAddress);
                AddressList.Remove(CurrentAddress);
                BubbleClient.RemoveAddressAsync(CurrentAddress);
            });
            DeletePhoneCommand = new DelegateCommand(() => {

                CurrentPerson.plist.Remove(CurrentPhone);
                PhoneList.Remove(CurrentPhone);
                BubbleClient.RemovePhoneAsync(CurrentPhone);
            });
            DeleteEmailCommand = new DelegateCommand(() => {

                CurrentPerson.elist.Remove(CurrentEmail);
                EmailList.Remove(CurrentEmail);
                BubbleClient.RemoveEmailAsync(CurrentEmail);
            });
        }