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