25 lines
		
	
	
		
			627 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			627 B
		
	
	
	
		
			C#
		
	
	
	
	
	
| using Core.Entities;
 | |
| using Core.Interfaces;
 | |
| using Microsoft.EntityFrameworkCore;
 | |
| 
 | |
| namespace Infrastructure.Data
 | |
| {
 | |
|     public class ProductRepository : iProductRepository
 | |
|     {
 | |
|         private readonly StoreContext _context;
 | |
|         public ProductRepository(StoreContext context)
 | |
|         {
 | |
|             _context = context;
 | |
|         }
 | |
| 
 | |
|         public async Task<Product> GetProductByIdAsync(int id)
 | |
|         {
 | |
|             return await _context.Products.FindAsync(id);
 | |
|         }
 | |
| 
 | |
|         public async Task<IReadOnlyList<Product>> GetProductsAync()
 | |
|         {
 | |
|             return await _context.Products.ToListAsync();
 | |
|         }
 | |
|     }
 | |
| } |