Exemplo n.º 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();
            }
        }
Exemplo n.º 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;
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }