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)); } }
public Store Get(int id) { using (var db = new MicroPOSDbContext()) { return(db.Stores.Include(x => x.Stocks).FirstOrDefault(x => x.Id == id)); } }
public List <Store> Get() { using (var db = new MicroPOSDbContext()) { return(db.Stores.Include(x => x.Stocks).ToList()); } }
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(); } }
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); } }