Exemplo n.º 1
0
        /// <summary>
        ///     Add a new Address to the database, and opens a dialog to edit that new address.
        /// </summary>
        public void Add()
        {
            using (var db = new MailerEntities())
            {
                var address = new Address
                {
                    FirstName = "",
                    LastName  = "",
                    Email     = "",
                };
                db.Addresses.Add(address);
                db.SaveChanges();


                var vm = new AddressListItemViewModel(address);
                if (vm.Edit() == true)
                {
                    AddAddressListItemViewModel(vm);
                }
                else
                {
                    db.Addresses.Remove(address);
                    db.SaveChanges();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Remove the specified AddressListItemViewModel from this AddressListViewModel.
 /// </summary>
 /// <param name="alivm">The AddressListItemViewModel to remove.</param>
 public void RemoveAddressListItemViewModel(AddressListItemViewModel alivm)
 {
     AddressListItemViewModelsUnfiltered.Remove(alivm);
     UpdateFilter();
 }
Exemplo n.º 3
0
 /// <summary>
 ///     Add the specified AddressListItemViewModel to this AddressListViewModel.
 /// </summary>
 /// <param name="alivm">The AddressListItemViewModel to add.</param>
 public void AddAddressListItemViewModel(AddressListItemViewModel alivm)
 {
     AddressListItemViewModelsUnfiltered.Add(alivm);
     UpdateFilter();
 }