コード例 #1
0
ファイル: Repository.cs プロジェクト: ncc2893/refproject
 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);
 }
コード例 #2
0
 public void Update(Employee employee)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     using (ITransaction transaction = session.BeginTransaction())
     {
         session.Update(employee);
         transaction.Commit();
     }
 }
コード例 #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);
        }
コード例 #4
0
ファイル: EmployeeService.cs プロジェクト: ncc2893/refproject
 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;
 }
コード例 #5
0
ファイル: Repository.cs プロジェクト: ncc2893/refproject
 public void UpdateEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Update(employee);
 }
コード例 #6
0
ファイル: Repository.cs プロジェクト: ncc2893/refproject
 public void DeleteEmployee(Employee employee)
 {
     IEmployeeRepository repository = new EmployeeRepository();
     repository.Delete(employee);
 }