public List <ProductGroup> Get()
 {
     using (var db = new MicroPOSDbContext())
     {
         return(db.ProductGroups.Include(x => x.SubGroups).ToList());
     }
 }
 public ProductGroup Get(int id)
 {
     using (var db = new MicroPOSDbContext())
     {
         return(db.ProductGroups.Include(x => x.SubGroups).FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #3
0
 public Store Get(int id)
 {
     using (var db = new MicroPOSDbContext())
     {
         return(db.Stores.Include(x => x.Stocks).FirstOrDefault(x => x.Id == id));
     }
 }
Beispiel #4
0
 public List <Store> Get()
 {
     using (var db = new MicroPOSDbContext())
     {
         return(db.Stores.Include(x => x.Stocks).ToList());
     }
 }
Beispiel #5
0
        public int Create(Product entity)
        {
            var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadUncommitted
            });

            using (scope)
            {
                using (var db = new MicroPOSDbContext())
                {
                    db.Products.Add(entity);
                    foreach (var storeId in entity.Stores)
                    {
                        if (storeId == 0)
                        {
                            continue;
                        }
                        var stock = new Stock {
                            ProductId = entity.Id, StoreId = storeId
                        };
                        db.Stocks.Add(stock);
                    }
                    db.SaveChanges();
                }

                scope.Complete();
                return(entity.Id);
            }
        }
        public void Update(ProductGroup entity)
        {
            var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadUncommitted
            });

            using (scope)
            {
                using (var db = new MicroPOSDbContext())
                {
                    db.ProductGroups.AddOrUpdate(entity);
                    db.SaveChanges();
                }

                scope.Complete();
            }
        }
Beispiel #7
0
        public int Create(Store entity)
        {
            var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                IsolationLevel = IsolationLevel.ReadUncommitted
            });

            using (scope)
            {
                using (var db = new MicroPOSDbContext())
                {
                    db.Stores.Add(entity);
                    db.SaveChanges();
                }

                scope.Complete();
                return(entity.Id);
            }
        }