Example #1
0
 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);
 }
Example #2
0
 public void Update(Employee employee)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Update(employee);
         transaction.Commit();
     }
 }
Example #3
0
        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);
        }
Example #4
0
 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;
 }
Example #5
0
 public void UpdateEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Update(employee);
 }
Example #6
0
 public void DeleteEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Delete(employee);
 }