示例#1
0
 public void UpdateEmployee(Employee employee)
 {
     using (var context = new HumanResourceContext())
     {
         context.Entry <Employee>(employee).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
示例#2
0
 public void DeleteDepartment(Department department)
 {
     using (var context = new HumanResourceContext())
     {
         context.Entry <Department>(department).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
示例#3
0
 public void AddEmployee(Employee employee)
 {
     using (var context = new HumanResourceContext())
     {
         context.Employees.Add(employee);
         context.SaveChanges();
     }
 }
示例#4
0
 public void AddDepartment(Department department)
 {
     using (var context = new HumanResourceContext())
     {
         context.Departments.Add(department);
         context.SaveChanges();
     }
 }
示例#5
0
 public void DeleteEmployee(Employee employee)
 {
     using (var context = new HumanResourceContext())
     {
         Employee theEmployee = GetEmployee(employee.Id);
         context.Entry <Employee>(theEmployee).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
示例#6
0
        public Employee GetEmployee(int employeeId)
        {
            Employee employee;

            using (var context = new HumanResourceContext())
            {
                employee = context.Employees.Find(employeeId);
            }
            return(employee);
        }
示例#7
0
        public IEnumerable <Employee> GetAllEmployees()
        {
            IEnumerable <Employee> employees;

            using (var context = new HumanResourceContext())
            {
                employees = context.Employees.Include("Department").ToList();
            }
            return(employees);
        }
示例#8
0
        public Department GetDepartment(int departmentId)
        {
            Department department;

            using (var context = new HumanResourceContext())
            {
                department = context.Departments.Find(departmentId);
            }
            return(department);
        }
示例#9
0
        public IEnumerable <Department> GetAllDepartments()
        {
            IEnumerable <Department> departments;

            using (var context = new HumanResourceContext())
            {
                departments = context.Departments.ToList();
            }
            return(departments);
        }