Exemple #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);
 }
 public void TestGetAllEmployees()
 {
     IEmployeeRepository repository = new EmployeeRepository(); //reminder: use a factory to get the configured concrete instance.
         var all = repository.GetAllEmployees();
         foreach (Employee employee in all)
         {
             Console.WriteLine("Firstname: {0} Surname: {1} Birthdate: {2} EmployeeNumber: {3} TerminationDate: {4}", employee.FirstName, employee.LastName,
             employee.BirthDate, employee.EmployeeNum, employee.TerminationDate);
         }
 }
        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);
        }
Exemple #4
0
 public void UpdateEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Update(employee);
 }
Exemple #5
0
 public Employee GetEmployee(int employeeId)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     return repository.GetEmployee(employeeId);
 }
Exemple #6
0
 //I'd also return an IQueryable object here so as enjoy benefits of LINQ.
 public ICollection<Employee> GetAllEmployees()
 {
     IEmployeeRepository repository = new EmployeeRepository();
     return repository.GetAllEmployees();
 }
Exemple #7
0
 public void DeleteEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Delete(employee);
 }