예제 #1
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);
            }
        }
예제 #2
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);
            }
        }