Beispiel #1
0
        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);
        }
Beispiel #2
0
        // 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);
            }
        }
Beispiel #3
0
        // 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);
            }
        }
Beispiel #4
0
 protected override Department GetEntity(EIMSDataContext entityContext, int id)
 {
     return(entityContext.Departments.Where(d => d.DepartmentId == id).FirstOrDefault());
 }
Beispiel #5
0
 protected override IEnumerable <Department> GetEntities(EIMSDataContext entityContext)
 {
     return(entityContext.Departments.ToList());
 }
Beispiel #6
0
 protected override Department UpdateEntity(EIMSDataContext entityContext, Department entity)
 {
     return((from e in entityContext.Departments
             where e.DepartmentId == entity.DepartmentId
             select e).FirstOrDefault());
 }
Beispiel #7
0
 protected override Department AddEntity(EIMSDataContext entityContext, Department entity)
 {
     return(entityContext.Departments.Add(entity));
 }
Beispiel #8
0
 protected override IEnumerable <Employee> GetEntities(EIMSDataContext entityContext)
 {
     return((from e in entityContext.Employees
             select e).Include(e => e.Department));
 }
Beispiel #9
0
 protected override Employee UpdateEntity(EIMSDataContext entityContext, Employee entity)
 {
     return((from e in entityContext.Employees
             where e.EmployeeId == entity.EmployeeId
             select e).FirstOrDefault());
 }
Beispiel #10
0
 protected override Employee AddEntity(EIMSDataContext entityContext, Employee entity)
 {
     return(entityContext.Employees.Add(entity));
 }