Beispiel #1
0
 public async Task <List <Product> > GetAll()
 {
     using (var db = new CyzaTestEntities())
     {
         return(await db.Products.Include(p => p.Stock).ToListAsync());
     }
 }
Beispiel #2
0
 public async Task <Supplier> GetById(params object[] id)
 {
     using (var db = new CyzaTestEntities())
     {
         return(await db.Suppliers.FindAsync(id));
     }
 }
Beispiel #3
0
 public async Task <List <Supplier> > GetAll()
 {
     using (var db = new CyzaTestEntities())
     {
         return(await db.Suppliers.ToListAsync());
     }
 }
Beispiel #4
0
 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));
     }
 }
Beispiel #5
0
 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());
     }
 }
Beispiel #6
0
 public async Task <int> Delete(Product product)
 {
     using (var db = new CyzaTestEntities())
     {
         var repository = new ProductRepository(db);
         repository.Delete(product);
         return(await db.SaveChangesAsync());
     }
 }
Beispiel #7
0
 public async Task <int> Delete(Supplier supplier)
 {
     using (var db = new CyzaTestEntities())
     {
         var repository = new SupplierRepository(db);
         repository.Delete(supplier);
         return(await db.SaveChangesAsync());
     }
 }
Beispiel #8
0
 public async Task <int> Update(SupplierProduct supplierProduct)
 {
     using (var db = new CyzaTestEntities())
     {
         var repository = new SupplierProductRepository(db);
         repository.Update(supplierProduct);
         return(await db.SaveChangesAsync());
     }
 }
Beispiel #9
0
        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());
            }
        }
Beispiel #10
0
 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());
     }
 }
Beispiel #11
0
 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());
     }
 }
Beispiel #12
0
        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));
            }
        }
Beispiel #13
0
 public SupplierRepository(CyzaTestEntities context) : base(context)
 {
 }
Beispiel #14
0
 public ProductRepository(CyzaTestEntities context) : base(context)
 {
 }
Beispiel #15
0
 public StockMovementRepository(CyzaTestEntities context) : base(context)
 {
 }
Beispiel #16
0
 protected Repository(CyzaTestEntities context)
 {
     Context = context;
 }