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); } }