Beispiel #1
0
        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            Client client = new Client
            {
                NameEng = "testUser1"
            };

            using (var context = new EntitiesContext())
            {
                context.Clients.Add(client);
                context.SaveChanges();
            }
        }
Beispiel #2
0
        public ObservableCollection<Client> GetClients()
        {
            var clients = new ObservableCollection<Client>();

            using (var context = new EntitiesContext())
            {
                foreach (var item in context.Clients)
                {
                    clients.Add(item);
                }
            }

            return clients;
        }
Beispiel #3
0
 public void SaveClient(Client client)
 {
     using (var context = new EntitiesContext())
     {
         if (client.ClientID != 0)
         {
             context.Entry(client).State = EntityState.Modified;
         }
         else
         {
             context.Entry(client).State = EntityState.Added;
         }
         context.SaveChanges();
     }
 }
Beispiel #4
0
 public Client GetClient(int clientId)
 {
     Client client;
     using (var context = new EntitiesContext())
     {
         client = (from c in context.Clients
                       where c.ClientID == clientId
                       select c).FirstOrDefault();
     }
     return client;
 }
Beispiel #5
0
        public ObservableCollection<Case> GetCases()
        {
            var cases = new ObservableCollection<Case>();

            using (var context = new EntitiesContext())
            {
                foreach (var item in context.Cases)
                {
                    cases.Add(item);
                }
            }
            return cases;
        }