public ProductController(ILogger <ProductController> logger, IProductService productService, GMartDbContext db, IHttpContextAccessor httpContextAccessor)
 {
     _logger              = logger;
     _db                  = db;
     _productService      = productService;
     _httpContextAccessor = httpContextAccessor;
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public ProductTypeRepo(GMartDbContext gMartDbContext) : base(gMartDbContext)
 {
     _gMartDbContext = gMartDbContext;
 }
 public ProductSqlService(GMartDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Exemplo n.º 5
0
 public UnitOfWork(GMartDbContext gMartDbContext)//gmartdbcontext added for DI by gmartui startup configureservices
 {
     _gMartDbContext   = gMartDbContext;
     productRepository = new ProductRepository(_gMartDbContext);
     productTypeRepo   = new ProductTypeRepo(_gMartDbContext);
 }
Exemplo n.º 6
0
 public ProductService(GMartDbContext gMartDbContext)
 {
     _gMartDbContext = gMartDbContext;
     prodRepo        = new ProductRepository(_gMartDbContext);
 }
Exemplo n.º 7
0
 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>();
 }
Exemplo n.º 8
0
 public ProductRepository(GMartDbContext gMartDbContext) : base(gMartDbContext)
 {
     _gMartDbContext = gMartDbContext;
 }