public async Task <List <Product> > GetAll() { using (var db = new CyzaTestEntities()) { return(await db.Products.Include(p => p.Stock).ToListAsync()); } }
public async Task <Supplier> GetById(params object[] id) { using (var db = new CyzaTestEntities()) { return(await db.Suppliers.FindAsync(id)); } }
public async Task <List <Supplier> > GetAll() { using (var db = new CyzaTestEntities()) { return(await db.Suppliers.ToListAsync()); } }
public async Task <Product> GetById(int id) { using (var db = new CyzaTestEntities()) { return(await db.Products.Include(p => p.Stock) .SingleOrDefaultAsync(p => p.Id == id)); } }
public async Task <List <Product> > FindProductsNotAssigned(int supplierId) { using (var db = new CyzaTestEntities()) { return(await db.Products .Where(p => p.SupplierProducts.All(sp => sp.SupplierId != supplierId)).ToListAsync()); } }
public async Task <int> Delete(Product product) { using (var db = new CyzaTestEntities()) { var repository = new ProductRepository(db); repository.Delete(product); return(await db.SaveChangesAsync()); } }
public async Task <int> Delete(Supplier supplier) { using (var db = new CyzaTestEntities()) { var repository = new SupplierRepository(db); repository.Delete(supplier); return(await db.SaveChangesAsync()); } }
public async Task <int> Update(SupplierProduct supplierProduct) { using (var db = new CyzaTestEntities()) { var repository = new SupplierProductRepository(db); repository.Update(supplierProduct); return(await db.SaveChangesAsync()); } }
public async Task <int> Outbound(StockMovement stockMovement) { using (var db = new CyzaTestEntities()) { var repository = new StockMovementRepository(db); await repository.Outbound(stockMovement); return(await db.SaveChangesAsync()); } }
public async Task <List <SupplierProduct> > GetBySupplierId(int supplierId) { using (var db = new CyzaTestEntities()) { return(await db.SupplierProducts .Include(sp => sp.Supplier) .Include(sp => sp.Product) .Where(sp => sp.SupplierId == supplierId).ToListAsync()); } }
public async Task <List <StockMovement> > GetByUser(string userId) { using (var db = new CyzaTestEntities()) { return(await db.StockMovements .Include(sm => sm.SupplierProduct) .Include(sm => sm.SupplierProduct.Product) .Include(sm => sm.SupplierProduct.Supplier) .Where(sm => sm.UserId == userId).ToListAsync()); } }
public async Task <SupplierProduct> GetById(params int[] id) { var supplierId = id[0]; var productId = id[1]; using (var db = new CyzaTestEntities()) { return(await db.SupplierProducts .Include(sp => sp.Product) .Include(sp => sp.Supplier) .SingleOrDefaultAsync(sp => sp.SupplierId == supplierId && sp.ProductId == productId)); } }
public SupplierRepository(CyzaTestEntities context) : base(context) { }
public ProductRepository(CyzaTestEntities context) : base(context) { }
public StockMovementRepository(CyzaTestEntities context) : base(context) { }
protected Repository(CyzaTestEntities context) { Context = context; }