public List <Category> GetCategories(int id) { using var context = new E_CommerceContext(); return(context.Products.Join(context.productCategories, product => product.Id, productcategory => productcategory.ProductID, (p, pc) => new { product = p, productcategory = pc }).Join(context.Categories, x => x.productcategory.CategoryID, c => c.Id, (pc, c) => new { product = pc.product, category = c, productcategory = pc.productcategory }).Where (x => x.product.Id == id).Select(x => new Category { Name = x.category.Name, Id = x.category.Id, }).ToList()); }
public void Add(TEntity entity) { using var context = new E_CommerceContext(); context.Set <TEntity>().Add(entity); context.SaveChanges(); }
public TEntity GetEntity(int id) { using var context = new E_CommerceContext(); return(context.Set <TEntity>().Find(id)); }
public List <TEntity> GetAll() { using var context = new E_CommerceContext(); return(context.Set <TEntity>().ToList()); }
public void Delete(TEntity entity) { using var context = new E_CommerceContext(); context.Set <TEntity>().Remove(entity); context.SaveChanges(); }
public ProductController(E_CommerceContext context) { _context = context; }
public CustomerController(E_CommerceContext context) { _context = context; }
public OrderController(E_CommerceContext context) { _context = context; }
public HomeController(E_CommerceContext context) { _context = context; }