Ejemplo n.º 1
0
        public void DeleteEmployee(Employee Employee)
        {
            Employee = EmployeeDao.GetEmployeeByName(Employee.Name);

            if (Employee != null)
            {
                EmployeeDao.DeleteEmployee(Employee);
            }
        }
Ejemplo n.º 2
0
 public void DeleteEmployee(Employee Employee)
 {
     try
     {
         EmployeeService.DeleteEmployee(Employee);
     }
     catch (Exception)
     {
         throw new HttpResponseException(HttpStatusCode.InternalServerError);
     }
 }
Ejemplo n.º 3
0
        public Employee AddEmployee(Employee Employee)
        {
            CheckEmployeeIsNotNullThrowException(Employee);

            try
            {
                return EmployeeService.AddEmployee(Employee);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
Ejemplo n.º 4
0
        public Employee UpdateEmployee(Employee Employee)
        {
            CheckEmployeeIsNullThrowException(Employee);

            try
            {
                EmployeeService.UpdateEmployee(Employee);
                return EmployeeService.GetEmployeeByName(Employee.Name);
            }
            catch (Exception)
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
        public void TestEmployeeDao_AddEmployee()
        {
            Employee Employee = new Employee();
            Employee.Id = "UnitTests";
            Employee.Name = "單元測試";
            Employee.Description = "請做出單元測試";
            EmployeeDao.AddEmployee(Employee);

            Employee dbEmployee = EmployeeDao.GetEmployeeByName(Employee.Name);
            Assert.IsNotNull(dbEmployee);
            Assert.AreEqual(Employee.Name, dbEmployee.Name);

            Console.WriteLine("員工編號為 = " + dbEmployee.Id);
            Console.WriteLine("員工名稱為 = " + dbEmployee.Name);
            Console.WriteLine("員工描述為 = " + dbEmployee.Description);

            EmployeeDao.DeleteEmployee(dbEmployee);
            dbEmployee = EmployeeDao.GetEmployeeByName(Employee.Name);
            Assert.IsNull(dbEmployee);
        }
Ejemplo n.º 6
0
 public void UpdateEmployee(Employee Employee)
 {
     EmployeeDao.UpdateEmployee(Employee);
 }
Ejemplo n.º 7
0
 public Employee AddEmployee(Employee Employee)
 {
     EmployeeDao.AddEmployee(Employee);
     return GetEmployeeByName(Employee.Name);
 }
Ejemplo n.º 8
0
        /// <summary>
        ///     檢查課程資料是否存在,如果不存在則拋出錯誤.
        /// </summary>
        /// <param name="course">
        ///     課程資料.
        /// </param>
        private void CheckEmployeeIsNullThrowException(Employee Employee)
        {
            Employee dbEmployee = EmployeeService.GetEmployeeById(Employee.Id);

            if (dbEmployee == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }
        }