protected async Task ExecuteInTransaction(Func <Task> action) { using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { await action(); await _dbContext.SaveChangesAsync(); transaction.Commit(); } }
public async Task <Capability> CreateCapability(string name, string description) { using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { var capability = await _inner.CreateCapability(name, description); await _dbContext.SaveChangesAsync(); transaction.Commit(); return(capability); } }
public async Task <Capability> UpdateCapability(Guid capabilityId, string newName, string newDescription) { using (var transaction = await _dbContext.Database.BeginTransactionAsync()) { var cap = await _inner.UpdateCapability(capabilityId, newName, newDescription); await _dbContext.SaveChangesAsync(); transaction.Commit(); return(cap); } }
public async Task Add(Capability capability) { await _dbContext.Capabilities.AddAsync(capability); await _dbContext.SaveChangesAsync(); }