public void UpdateEmployee(Employee employee) { using (var context = new HumanResourceContext()) { context.Entry <Employee>(employee).State = EntityState.Modified; context.SaveChanges(); } }
public void DeleteDepartment(Department department) { using (var context = new HumanResourceContext()) { context.Entry <Department>(department).State = EntityState.Deleted; context.SaveChanges(); } }
public void AddEmployee(Employee employee) { using (var context = new HumanResourceContext()) { context.Employees.Add(employee); context.SaveChanges(); } }
public void AddDepartment(Department department) { using (var context = new HumanResourceContext()) { context.Departments.Add(department); context.SaveChanges(); } }
public void DeleteEmployee(Employee employee) { using (var context = new HumanResourceContext()) { Employee theEmployee = GetEmployee(employee.Id); context.Entry <Employee>(theEmployee).State = EntityState.Deleted; context.SaveChanges(); } }
public Employee GetEmployee(int employeeId) { Employee employee; using (var context = new HumanResourceContext()) { employee = context.Employees.Find(employeeId); } return(employee); }
public IEnumerable <Employee> GetAllEmployees() { IEnumerable <Employee> employees; using (var context = new HumanResourceContext()) { employees = context.Employees.Include("Department").ToList(); } return(employees); }
public Department GetDepartment(int departmentId) { Department department; using (var context = new HumanResourceContext()) { department = context.Departments.Find(departmentId); } return(department); }
public IEnumerable <Department> GetAllDepartments() { IEnumerable <Department> departments; using (var context = new HumanResourceContext()) { departments = context.Departments.ToList(); } return(departments); }