public bool UpdateEmployee(Bas_Employee employee, Bas_EmployeeRole bas_EmployeeRole) { bool result = false; using (TransactionScope scope = new TransactionScope()) { try { BeginTran(); Bas_Role bas_Role = BllRoleRepository.GetEntityRoleByCode(employee.Bem_Roles); result = BllEmployeeRepository.Update(employee); if (result) { Bas_EmployeeRole bas_EmployeeRoleData = EmployeeRoleRepository.GetEmployeeRoleByEmployeeId(employee.Bem_Id); bas_EmployeeRole.ber_Id = bas_EmployeeRoleData.ber_Id; bas_EmployeeRole.Ber_EmployeeId = employee.Bem_Id; bas_EmployeeRole.Ber_RoleId = bas_Role.Bro_Id; result = EmployeeRoleRepository.Update(bas_EmployeeRole); } if (result) { scope.Complete(); } else { RollbackTran(); } } catch (Exception ex) { RollbackTran(); result = false; } } return(result); }
public bool AddEmployee(Bas_Employee employee, Bas_EmployeeRole bas_EmployeeRole) { bool result = false; using (TransactionScope scope = new TransactionScope()) { try { BeginTran(); Bas_Role bas_Role = BllRoleRepository.GetEntityRoleByCode(employee.Bem_Roles); int value = BllEmployeeRepository.Add(employee); result = value > 0; if (result) { bas_EmployeeRole.Ber_EmployeeId = value; bas_EmployeeRole.Ber_RoleId = bas_Role.Bro_Id; result = EmployeeRoleRepository.Add(bas_EmployeeRole) > 0; } if (result) { scope.Complete(); } else { RollbackTran(); } } catch (Exception ex) { RollbackTran(); result = false; throw ex; } } return(result); }