Exemple #1
0
 private void ShowDetails(int id)
 {
     using (var context = new LocationPhotoManagerEntities())
     {
         owner = context.OwnerSet.First(x => x.Id == id);
         owner.AdressSet.ToList().ForEach(x => Adresses.Add(x));
     }
     icon = owner.Company ? "Photos/Icon/Company.png" : "Photos/Icon/Person.png";
 }
        private void Delete(object sender, RoutedEventArgs e)
        {
            var tag = (OwnerSet)((Button)sender).Tag;

            using (var context = new LocationPhotoManagerEntities())
            {
                context.OwnerSet.Remove(context.OwnerSet.FirstOrDefault(x => x.Id == tag.Id));
                context.SaveChanges();
            }
            UpdateView();
        }
        public void UpdateView()
        {
            owners = new ObservableCollection <OwnerDisplay>();

            // get All owners
            using (var context = new LocationPhotoManagerEntities())
            {
                context.OwnerSet.ToList().ForEach(x => owners.Add(new OwnerDisplay
                {
                    Owner = x,
                    Icon  = x.Company
                        ? Properties.Settings.Default.Company
                        : Properties.Settings.Default.Person
                }));
            }
            if (OwnerList != null)
            {
                OwnerList.ItemsSource = owners;
            }
        }
Exemple #4
0
 private void Create(object sender, RoutedEventArgs e)
 {
     if (Person.Text == string.Empty)
     {
         MessageBox.Show("Assigned Person can't be empty", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
     }
     else
     {
         using (var context = new LocationPhotoManagerEntities())
         {
             context.OwnerSet.Add(new OwnerSet
             {
                 AssignedPerson = Person.Text,
                 Company        = (bool)IsCompany.IsChecked,
                 Email          = Mail.Text,
                 Phone          = Phone.Text
             });
             context.SaveChanges();
         }
         Close();
         _window.Show();
         _window.UpdateView();
     }
 }