| | | 1 | | using OzonDomains.Models; |
| | | 2 | | using OzonRepositories.Data; |
| | | 3 | | |
| | | 4 | | namespace Services.DataServices |
| | | 5 | | { |
| | | 6 | | public class ProductsDataServices : IDataServices |
| | | 7 | | { |
| | | 8 | | private readonly ProductRepository _repository; |
| | | 9 | | |
| | 0 | 10 | | public ProductsDataServices(ProductRepository repository) |
| | | 11 | | { |
| | 0 | 12 | | _repository = repository; |
| | 0 | 13 | | } |
| | | 14 | | |
| | | 15 | | public async Task<int> AddProduct(Product value) |
| | | 16 | | { |
| | 0 | 17 | | return await _repository.Add(value); |
| | 0 | 18 | | } |
| | | 19 | | |
| | | 20 | | public async Task<int> DeleteProduct(Product value) |
| | | 21 | | { |
| | 0 | 22 | | return await _repository.Delete(value); |
| | 0 | 23 | | } |
| | | 24 | | |
| | | 25 | | public async Task<List<Product>> GetProducts() |
| | | 26 | | { |
| | 0 | 27 | | return await _repository.Get(); |
| | 0 | 28 | | } |
| | | 29 | | |
| | | 30 | | public async Task<Product?> GetProductAsync(int id) |
| | | 31 | | { |
| | 0 | 32 | | return await _repository.GetAsync(id); |
| | 0 | 33 | | } |
| | | 34 | | |
| | | 35 | | public async Task<Product?> GetProductAsync(Product value) |
| | | 36 | | { |
| | 0 | 37 | | return await _repository.GetAsync(value); |
| | 0 | 38 | | } |
| | | 39 | | |
| | | 40 | | public async Task<int> Update(Product value) |
| | | 41 | | { |
| | 0 | 42 | | return await _repository.Update(value); |
| | 0 | 43 | | } |
| | | 44 | | public async Task<int> SaveChanges() |
| | | 45 | | { |
| | 0 | 46 | | return await _repository.SaveChanges(); |
| | 0 | 47 | | } |
| | | 48 | | |
| | | 49 | | /// <summary>Словарь article → ImageUrl для набора артикулов (offer_id).</summary> |
| | | 50 | | public async Task<Dictionary<string, string>> GetImageUrlsByArticlesAsync(IEnumerable<string> articles) |
| | | 51 | | { |
| | 0 | 52 | | return await _repository.GetImageUrlsByArticlesAsync(articles); |
| | 0 | 53 | | } |
| | | 54 | | } |
| | | 55 | | } |