|
| 1 | +using Inflow.Domain.Interfaces.Repositories; |
| 2 | +using Inflow.Infrastructure; |
| 3 | + |
| 4 | +namespace DiyorMarket.Infrastructure.Persistence.Repositories |
| 5 | +{ |
| 6 | + public class CommonRepository : ICommonRepository |
| 7 | + { |
| 8 | + private readonly InflowDbContext _context; |
| 9 | + |
| 10 | + private ICategoryRepository _category; |
| 11 | + public ICategoryRepository Category |
| 12 | + { |
| 13 | + get |
| 14 | + { |
| 15 | + _category ??= new CategoryRepository(_context); |
| 16 | + |
| 17 | + return _category; |
| 18 | + } |
| 19 | + } |
| 20 | + |
| 21 | + private IProductRepository _product; |
| 22 | + public IProductRepository Product |
| 23 | + { |
| 24 | + get |
| 25 | + { |
| 26 | + _product ??= new ProductRepository(_context); |
| 27 | + |
| 28 | + return _product; |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + private ICustomerRepository _customer; |
| 33 | + public ICustomerRepository Customer |
| 34 | + { |
| 35 | + get |
| 36 | + { |
| 37 | + _customer ??= new CustomerRepository(_context); |
| 38 | + |
| 39 | + return _customer; |
| 40 | + } |
| 41 | + } |
| 42 | + |
| 43 | + private ISaleRepository _sale; |
| 44 | + public ISaleRepository Sale |
| 45 | + { |
| 46 | + get |
| 47 | + { |
| 48 | + _sale ??= new SaleRepository(_context); |
| 49 | + |
| 50 | + return _sale; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + private ISaleItemRepository _saleItem; |
| 55 | + public ISaleItemRepository SaleItem |
| 56 | + { |
| 57 | + get |
| 58 | + { |
| 59 | + _saleItem ??= new SaleItemRepository(_context); |
| 60 | + |
| 61 | + return _saleItem; |
| 62 | + } |
| 63 | + } |
| 64 | + |
| 65 | + private ISupplierRepository _supplier; |
| 66 | + public ISupplierRepository Supplier |
| 67 | + { |
| 68 | + get |
| 69 | + { |
| 70 | + _supplier ??= new SupplierRepository(_context); |
| 71 | + |
| 72 | + return _supplier; |
| 73 | + } |
| 74 | + } |
| 75 | + |
| 76 | + private ISupplyRepository _supply; |
| 77 | + public ISupplyRepository Supply |
| 78 | + { |
| 79 | + get |
| 80 | + { |
| 81 | + _supply ??= new SupplyRepository(_context); |
| 82 | + |
| 83 | + return _supply; |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + private ISupplyItemRepository _supplyItem; |
| 88 | + public ISupplyItemRepository SupplyItem |
| 89 | + { |
| 90 | + get |
| 91 | + { |
| 92 | + _supplyItem ??= new SupplyItemRepository(_context); |
| 93 | + |
| 94 | + return _supplyItem; |
| 95 | + } |
| 96 | + } |
| 97 | + public CommonRepository(InflowDbContext context) |
| 98 | + { |
| 99 | + _context = context; |
| 100 | + |
| 101 | + _category = new CategoryRepository(context); |
| 102 | + _product = new ProductRepository(context); |
| 103 | + _customer = new CustomerRepository(context); |
| 104 | + _sale = new SaleRepository(context); |
| 105 | + _saleItem = new SaleItemRepository(context); |
| 106 | + _supplier = new SupplierRepository(context); |
| 107 | + _supply = new SupplyRepository(context); |
| 108 | + _supplyItem = new SupplyItemRepository(context); |
| 109 | + } |
| 110 | + |
| 111 | + public int SaveChanges() |
| 112 | + { |
| 113 | + return _context.SaveChanges(); |
| 114 | + } |
| 115 | + } |
| 116 | +} |
0 commit comments