11using TechInventory . Data . UnitOfWork ;
22using TechInventory . Data . Repository ;
3- using TechInventory . Data . Context ;
43using TechInventory . Models ;
54
65namespace TechInventory . Services . DeviceModel ;
76
87public class DeviceModelService : IDeviceModelService
98{
109 private readonly UnitOfWork _unitOfWork ;
11- private readonly IRepository < Models . DeviceModel > _repository ;
10+ private readonly IRepository < Models . DeviceModel > _deviceModelRepository ;
1211 private readonly IRepository < Models . Brand > _brandRepository ;
1312
14- public DeviceModelService ( InventoryDbContext context )
13+ public DeviceModelService ( IUnitOfWork unitOfWork )
1514 {
16- _unitOfWork = new UnitOfWork ( context ) ;
17- _repository = _unitOfWork . DeviceModelRepository ;
15+ _unitOfWork = ( UnitOfWork ) unitOfWork ;
16+ _deviceModelRepository = _unitOfWork . DeviceModelRepository ;
1817 _brandRepository = _unitOfWork . BrandRepository ;
1918 }
2019
@@ -24,18 +23,18 @@ public async Task<Result<bool>> CreateDeviceModel(Models.DeviceModel deviceModel
2423 if ( ! checkResult . IsSuccessful )
2524 return checkResult ;
2625
27- await _repository . CreateAsync ( deviceModel ) ;
26+ await _deviceModelRepository . CreateAsync ( deviceModel ) ;
2827 return await _unitOfWork . CommitAsync ( ) ;
2928 }
3029
3130 public async Task < Models . DeviceModel > GetDeviceModelById ( int id )
3231 {
33- return await _repository . GetAsync ( id ) ;
32+ return await _deviceModelRepository . GetAsync ( id ) ;
3433 }
3534
3635 public async Task < List < Models . DeviceModel > > GetAllDeviceModels ( )
3736 {
38- return await _repository . GetWhere ( null , "Brand" ) ;
37+ return await _deviceModelRepository . GetWhere ( null , "Brand" ) ;
3938 }
4039
4140 public async Task < Result < bool > > UpdateDeviceModel ( Models . DeviceModel deviceModel )
@@ -44,19 +43,19 @@ public async Task<Result<bool>> UpdateDeviceModel(Models.DeviceModel deviceModel
4443 if ( ! checkResult . IsSuccessful )
4544 return checkResult ;
4645
47- _repository . Update ( deviceModel ) ;
46+ _deviceModelRepository . Update ( deviceModel ) ;
4847 return await _unitOfWork . CommitAsync ( ) ;
4948 }
5049
5150 public Task < Result < bool > > DeleteDeviceModel ( int id )
5251 {
53- _repository . DeleteAsync ( id ) ;
52+ _deviceModelRepository . DeleteAsync ( id ) ;
5453 return _unitOfWork . CommitAsync ( ) ;
5554 }
5655
5756 public async Task < List < Models . DeviceModel > > GetDeviceModelsByBrandId ( int brandId )
5857 {
59- return await _repository . GetWhere ( m => m . BrandId == brandId ) ;
58+ return await _deviceModelRepository . GetWhere ( m => m . BrandId == brandId ) ;
6059 }
6160
6261 public async Task < Result < bool > > CheckIncludes ( Models . DeviceModel deviceModel )
0 commit comments