public void Save(IPayrollItemModel businessModel) { using (Repository = new PayrollItemRepository()) { Message = SaveSuccessMessage; Repository.Save(businessModel); } }
public void Save <T>(T businessModel) where T : IPayrollGroupModel { using (Entities = new kk_sp_payrollEntities()) { OpenConnection(); using (var transaction = Entities.Connection.BeginTransaction(TRANSACTION_ISOLATION)) { var payrollGroupRepository = new PayrollGroupRepository(Entities); payrollGroupRepository.Save(businessModel); var itemRepository = new PayrollItemRepository(Entities); foreach (var payrollItemModel in businessModel.ListPayrollItemModel) { payrollItemModel.PayrolGroupId = businessModel.Id; itemRepository.Save(payrollItemModel); } transaction.Commit(); CloseConnection(); payrollGroupRepository.Dispose(); itemRepository.Dispose(); } } }