public List <Customer> GetAllCustomers() { using (var context = new OrderSystemContext()) { return(context.Customers.AsNoTracking().ToList()); } }
public Customer FindCustomer(int?id) { using (var context = new OrderSystemContext()) { return(context.Customers.AsNoTracking().SingleOrDefault(c => c.CustomerId == id)); } }
public void RemoveCustomer(int id) { using (var context = new OrderSystemContext()) { context.Customers.Remove(context.Customers.Find(id)); context.SaveChanges(); } }
public void UpdateCustomer(Customer customer) { using (var context = new OrderSystemContext()) { context.Entry(customer).State = EntityState.Modified; context.SaveChanges(); } }
public void AddCustomer(Customer customer) { using (var context = new OrderSystemContext()) { context.Customers.Add(customer); context.SaveChanges(); } }
public void AddProduct(Product product) { using (var context = new OrderSystemContext()) { product.IsAvailable = true; context.Products.Add(product); context.SaveChanges(); } }
public void RemoveProduct(int id) { using (var context = new OrderSystemContext()) { context.Database .ExecuteSqlCommand ($"update products set isavailable=0 where productid={id}"); } }
public Product FindProduct(int?id) { using (var context = new OrderSystemContext()) { return(context.Products .AsNoTracking() .SingleOrDefault(p => p.ProductId == id)); } }
public List <CustomerViewModel> GetAllCustomers() { using (var context = new OrderSystemContext()) { return(context.Customers.AsNoTracking() .Select(c => new CustomerViewModel { CustomerId = c.CustomerId, Name = c.FirstName + " " + c.LastName, OrderCount = c.Orders.Count() }) .ToList()); } }
public CustomerViewModel FindCustomer(int?id) { using (var context = new OrderSystemContext()) { var cust = context.Customers.AsNoTracking() .Select(c => new CustomerViewModel { CustomerId = c.CustomerId, Name = c.FirstName + " " + c.LastName, OrderCount = c.Orders.Count(), Orders = c.Orders.Select( o => new OrderViewModel { OrderSource = o.OrderSource, CustomerId = o.CustomerId, OrderDate = o.OrderDate }).ToList() }) .FirstOrDefault(c => c.CustomerId == id); return(cust); } }
public WebSiteOrderData(OrderSystemContext context) { _context = context; }
public UOWWrappingGenericRepos(OrderSystemContext context) { _context = context; }
public CustomerData(OrderSystemContext context) { _context = context; }
public UOW(OrderSystemContext context) { _context = context; }
public List <Product> GetAllCustomers() { using (var context = new OrderSystemContext()) { return(context.Products.AsNoTracking().OrderBy(p => p.Name).ToList()); } }
public UOW() { _context = new OrderSystemContext(); }
public UOWWrappingGenericRepos() { _context = new OrderSystemContext(); }
public ProductData(OrderSystemContext context) { _context = context; }
public CustomerWithOrdersData_DI(OrderSystemContext context) { _context = context; }