public NorthwindUnitOfWork() { _dbContext = new NorthwindSlim(); _productsRepository = new ProductsRepository(_dbContext); _customersRepository = new CustomersRepository(_dbContext); _ordersRepository = new OrdersRepository(_dbContext); }
public async Task<IEnumerable<Customer>> GetCustomers() { using (var dbContext = new NorthwindSlim()) { var customers = await dbContext.Customers .OrderBy(p => p.CustomerId) .ToListAsync(); return customers; } }
public async Task<IHttpActionResult> Get() { using (var dbContext = new NorthwindSlim()) { var customers = await dbContext.Customers .OrderBy(p => p.CustomerId) .ToListAsync(); return Ok(customers); } }
public async Task<IEnumerable<Product>> GetProducts() { using (var db = new NorthwindSlim()) { var products = await db.Products .Include(p => p.Category) .OrderBy(p => p.ProductName) .ToListAsync(); return products; } }
public CustomersRepository(NorthwindSlim dbContext) { _dbContext = dbContext; }
public ProductsRepository(NorthwindSlim dbContext) { _dbContext = dbContext; }
public OrdersRepository(NorthwindSlim dbContext) { _dbContext = dbContext; }