protected override Employee GetEntity(EIMSDataContext entityContext, int id) { var query = (from e in entityContext.Employees where e.EmployeeId == id select e).Include(e => e.Department); var results = query.FirstOrDefault(); return(results); }
// Title and department can only updated by HR or admin public Employee UpdateBasicProfileInfo(Employee employee) { using (var entityContext = new EIMSDataContext()) { var existingEntity = UpdateEntity(entityContext, employee); SimpleMapper.PropertyMap(employee, existingEntity, new List <string>() { "Title", "Department" }); entityContext.SaveChanges(); return(existingEntity); } }
// Title and department can only updated by HR or admin public Employee UpdateFullProfileInfo(Employee employee) { using (var entityContext = new EIMSDataContext()) { var existingEntity = UpdateEntity(entityContext, employee); SimpleMapper.PropertyMap(employee, existingEntity, new List <string>() { "Title", "Department" }); if (employee.Department != null) { existingEntity.Department = entityContext.Departments.First(d => d.DepartmentId == employee.Department.DepartmentId); } entityContext.SaveChanges(); return(existingEntity); } }
protected override Department GetEntity(EIMSDataContext entityContext, int id) { return(entityContext.Departments.Where(d => d.DepartmentId == id).FirstOrDefault()); }
protected override IEnumerable <Department> GetEntities(EIMSDataContext entityContext) { return(entityContext.Departments.ToList()); }
protected override Department UpdateEntity(EIMSDataContext entityContext, Department entity) { return((from e in entityContext.Departments where e.DepartmentId == entity.DepartmentId select e).FirstOrDefault()); }
protected override Department AddEntity(EIMSDataContext entityContext, Department entity) { return(entityContext.Departments.Add(entity)); }
protected override IEnumerable <Employee> GetEntities(EIMSDataContext entityContext) { return((from e in entityContext.Employees select e).Include(e => e.Department)); }
protected override Employee UpdateEntity(EIMSDataContext entityContext, Employee entity) { return((from e in entityContext.Employees where e.EmployeeId == entity.EmployeeId select e).FirstOrDefault()); }
protected override Employee AddEntity(EIMSDataContext entityContext, Employee entity) { return(entityContext.Employees.Add(entity)); }