public ProductController(ILogger <ProductController> logger, IProductService productService, GMartDbContext db, IHttpContextAccessor httpContextAccessor) { _logger = logger; _db = db; _productService = productService; _httpContextAccessor = httpContextAccessor; }
public List <int> AddProducts(List <Product> newProductsList) { List <int> newProductsIDList = new List <int>(); try { foreach (Product product in newProductsList) { dbContext.Products.Add(product); newProductsIDList.Add(product.ID); } dbContext.SaveChanges(); } catch (Exception e) { dbContext = null; Console.WriteLine("Type:" + e.GetType().ToString() + " Message:" + e.Message); } return(newProductsIDList); }
public ProductTypeRepo(GMartDbContext gMartDbContext) : base(gMartDbContext) { _gMartDbContext = gMartDbContext; }
public ProductSqlService(GMartDbContext dbContext) { _dbContext = dbContext; }
public UnitOfWork(GMartDbContext gMartDbContext)//gmartdbcontext added for DI by gmartui startup configureservices { _gMartDbContext = gMartDbContext; productRepository = new ProductRepository(_gMartDbContext); productTypeRepo = new ProductTypeRepo(_gMartDbContext); }
public ProductService(GMartDbContext gMartDbContext) { _gMartDbContext = gMartDbContext; prodRepo = new ProductRepository(_gMartDbContext); }
public Repository(GMartDbContext db)//from DI configuration in startup of client e.g. startup of of MVC or webapi app { _db = db; this.dbset = _db.Set <T>(); }
public ProductRepository(GMartDbContext gMartDbContext) : base(gMartDbContext) { _gMartDbContext = gMartDbContext; }