Ejemplo n.º 1
0
 public void UpdateEmployee(Employee employee)
 {
     using (var context = new HumanResourceContext())
     {
         context.Entry <Employee>(employee).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
Ejemplo n.º 2
0
 public void DeleteDepartment(Department department)
 {
     using (var context = new HumanResourceContext())
     {
         context.Entry <Department>(department).State = EntityState.Deleted;
         context.SaveChanges();
     }
 }
Ejemplo n.º 3
0
 public void AddEmployee(Employee employee)
 {
     using (var context = new HumanResourceContext())
     {
         context.Employees.Add(employee);
         context.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 public void AddDepartment(Department department)
 {
     using (var context = new HumanResourceContext())
     {
         context.Departments.Add(department);
         context.SaveChanges();
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 6
0
        public Employee GetEmployee(int employeeId)
        {
            Employee employee;

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

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

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

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