public void AddEmployee(Employee employee) { //the following line is where I'd use dependency injection //scan configured assemblies and look for class than implements a type of interface (or has an particular attribute) IEmployeeRepository repository = new EmployeeRepository(); repository.Add(employee); }
public void Update(Employee employee) { using (ISession session = NHibernateHelper.OpenSession()) using (ITransaction transaction = session.BeginTransaction()) { session.Update(employee); transaction.Commit(); } }
public void TestAddNewEmployeeRecord() { var employer = new Employee { EmployedDate = DateTime.Now, FirstName = "Zahir", LastName = "Jacobs", BirthDate= new DateTime(1940,1,1), EmployeeNum = Guid.NewGuid().ToString("N").Substring(0,15), TerminationDate = new DateTime(1911,1,1) //not recommended, rather make type nullable but not time refigure how to define that in nhibernate }; IEmployeeRepository repository = new EmployeeRepository(); repository.Add(employer); }
public TransactionResponse AddEmployee(Employee employee) { TransactionResponse response = new TransactionResponse(); try { if (_configuration == null) Initialize(); RepositoryFactory rf = new RepositoryFactory(); rf.AddEmployee(employee); } catch (Exception ex) { response.Status.Success = false; response.Status.AddError("general", string.Format("{0} - {1}", MethodInfo.GetCurrentMethod().Name, ex.StackTrace)); } return response; }
public void UpdateEmployee(Employee employee) { IEmployeeRepository repository = new EmployeeRepository(); repository.Update(employee); }
public void DeleteEmployee(Employee employee) { IEmployeeRepository repository = new EmployeeRepository(); repository.Delete(employee); }