| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- // ======================================
- // Author: Ebenezer Monney
- // Email: info@ebenmonney.com
- // Copyright (c) 2017 www.ebenmonney.com
- //
- // ==> Gun4Hire: contact@ebenmonney.com
- // ======================================
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using DAL.Repositories;
- using DAL.Repositories.Interfaces;
- namespace DAL
- {
- public class UnitOfWork : IUnitOfWork
- {
- readonly ApplicationDbContext _context;
- ICustomerRepository _customers;
- IProductRepository _products;
- IOrdersRepository _orders;
- public UnitOfWork(ApplicationDbContext context)
- {
- _context = context;
- }
- public ICustomerRepository Customers
- {
- get
- {
- if (_customers == null)
- _customers = new CustomerRepository(_context);
- return _customers;
- }
- }
- public IProductRepository Products
- {
- get
- {
- if (_products == null)
- _products = new ProductRepository(_context);
- return _products;
- }
- }
- public IOrdersRepository Orders
- {
- get
- {
- if (_orders == null)
- _orders = new OrdersRepository(_context);
- return _orders;
- }
- }
- public int SaveChanges()
- {
- return _context.SaveChanges();
- }
- }
- }
|