Esempio n. 1
0
 public Transaction GetById(Guid id)
 {
     using (var context = new RepositoryContext())
     {
         return context.TransactionCollection.First(x => x.TransactionID == id);
     }
 }
Esempio n. 2
0
 public Customer GetByName(string name, string surname)
 {
     using (var context = new RepositoryContext())
     {
         IQueryable<Customer> query = context.Set<Customer>().Include("Transactions");
         return query.First(x => x.Name == name && x.Surmame==surname);
     }
 }
Esempio n. 3
0
 public Customer GetById(Guid id)
 {
     using (var context = new RepositoryContext())
     {
         IQueryable<Customer> query = context.Set<Customer>().Include("Transactions");
         return query.First(x => x.CustomerID == id);
     }
 }
Esempio n. 4
0
 public IEnumerable<Customer> GetAll()
 {
     using (var context = new RepositoryContext())
     {
         IQueryable<Customer> query= context.Set<Customer>().Include("Transactions");
         return query.ToList();
     }
 }
Esempio n. 5
0
 public void Add(Customer customer)
 {
     using (var context = new RepositoryContext())
     {
         context.CustomersCollection.Add(customer);
         context.SaveChanges();
     }
 }
Esempio n. 6
0
 public void Add(Transaction customer)
 {
     using (var context = new RepositoryContext())
     {
         context.CustomersCollection.Attach(customer.Customer);
         context.TransactionCollection.Add(customer);
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 public void UpdateCustomer(Customer customer)
 {
     using (var context = new RepositoryContext())
     {
         context.CustomersCollection.Attach(customer);
         var entry = context.Entry(customer);
         entry.Property(x => x.Name).IsModified = true;
         entry.Property(x => x.Surmame).IsModified = true;
         context.SaveChanges();
     }
 }