public async Task <int> Insert(Bill bill) { using (var session = new Session()) { var uow = session.UnitOfWork; _strategy = new FifoStrategy(); _billsRepository = new BillsRepository(uow); uow.Begin(); try { var billId = await _billsRepository.InsertUow(bill); await _strategy.UpdateAverageCostUow(Direction.Sale, bill, uow); uow.Commit(); return(billId); } catch (Exception e) { uow.RollBack(); throw e; } } }