예제 #1
0
        public ActionResult Set(int cId, int type, int bId)
        {
            var classDate = classService.GetClassesInfoById(new EntityDto <long>()
            {
                Id = cId
            });                                    //班级数据
            var create = new ClassDepJobEditDto(); //实例化对象Bound对象

            create.ClassId   = Convert.ToInt32(classDate.Id);
            create.ClassName = classDate.ClassesName;
            create.type      = type;

            var edit = classService.GetClassesInfoForEdit(new NullableIdDto <long> {
                Id = create.ClassId
            }).ClassesInfo;                                                                                            //更新人数对象

            switch (type)
            {
            case (int)ConfigureType.Department:

                if (IsChildren(cId, bId))
                {
                    return(Warn("已经有父级部门绑定了班级"));
                }
                IsParent(cId, bId);
                SetForDepart(edit, create, bId, cId);
                break;

            case (int)ConfigureType.Post:
                SetForPost(edit, create, bId, cId);
                break;
            }

            return(Success());
        }
        /// <summary>
        /// 新增班级和部门或岗位
        /// </summary>
        public ClassDepJobEditDto CreateClassDepJob(ClassDepJobEditDto input)
        {
            //TODO:新增前的逻辑判断,是否允许新增

            var entity = input.MapTo <ClassDepJob>();

            entity = _ClassDepJobRepository.Insert(entity);
            return(entity.MapTo <ClassDepJobEditDto>());
        }
        /// <summary>
        /// 编辑班级和部门或岗位
        /// </summary>
        public void UpdateClassDepJob(ClassDepJobEditDto input)
        {
            //TODO:更新前的逻辑判断,是否允许更新

            var entity = _ClassDepJobRepository.Get(input.Id.Value);

            input.MapTo(entity);

            _ClassDepJobRepository.Update(entity);
        }
        /// <summary>
        /// 通过Id获取班级和部门或岗位信息进行编辑或修改
        /// </summary>
        public GetClassDepJobForEditOutput GetClassDepJobForEdit(NullableIdDto <long> input)
        {
            var output = new GetClassDepJobForEditOutput();

            ClassDepJobEditDto ClassDepJobEditDto;

            if (input.Id.HasValue)
            {
                var entity = _ClassDepJobRepository.Get(input.Id.Value);
                ClassDepJobEditDto = entity.MapTo <ClassDepJobEditDto>();
            }
            else
            {
                ClassDepJobEditDto = new ClassDepJobEditDto();
            }

            output.ClassDepJob = ClassDepJobEditDto;
            return(output);
        }
예제 #5
0
        /// <summary>
        /// 设置部门
        /// </summary>
        /// <param name="edit"></param>
        /// <param name="create"></param>
        /// <param name="bId"></param>
        /// <param name="cId"></param>
        protected void SetForDepart(ClassesInfoEditDto edit, ClassDepJobEditDto create, int bId, int cId)
        {
            IsParent(cId, bId);
            //不重复人数
            var cuserids   = new List <int>();//班级当前人数
            var department = departmentService.GetAllDepartmentInfos().FirstOrDefault(t => t.DepartmentId == bId);

            if (department != null)
            {
                create.BusinessId   = bId;
                create.BusinessName = department.DisplayName;
                //获取当前子部门及自己的部门id
                var dids = departmentService.GetAllDepartmentInfos().Where(t => t.Path.Contains(department.Path)).Select(t => t.DepartmentId);

                //获取人员表当前选中部门ids的总人数
                var userids = userService.GetAll().Where(t => dids.Contains(t.DepartmentID)).Select(t => t.SysNO).ToList();

                foreach (var item in userids)
                {
                    //班级中已绑定的人员id
                    cuserids = classUserService.GetAll().Where(t => t.ClassId == cId).Select(t => t.UserId).ToList();
                    if (!cuserids.Contains(item))
                    {
                        classUserService.CreateClassUser(new ClassUserEditDto {
                            ClassId = cId, UserId = item
                        });
                    }
                    //判断课程班级表有当前班级没用如果有要更新课程人员表保持一致和手机签到一样
                    var dto = cbtservic.GetAll().FirstOrDefault(t => t.BusinessId == cId && t.type == 2);
                    if (dto != null && dto.type != 4)
                    {
                        cpservic.CreateCourseBoundPersonnel(new CourseBoundPersonnelEditDto {
                            CourseId = dto.CourseId, AccountSysNo = item, CheckIN = false, IsBound = true
                        });
                    }
                }
                cdjService.CreateClassDepJob(create);
            }
        }
예제 #6
0
        /// <summary>
        /// 设置岗位
        /// </summary>
        /// <param name="edit"></param>
        /// <param name="create"></param>
        /// <param name="bId"></param>
        /// <param name="cId"></param>
        protected void SetForPost(ClassesInfoEditDto edit, ClassDepJobEditDto create, int bId, int cId)
        {
            var cuserids = new List <int>();//班级当前人数
            var post     = jobPostService.GetJobPostById(new EntityDto <long>()
            {
                Id = bId
            });

            if (post != null)
            {
                create.BusinessId   = (int)post.Id;
                create.BusinessName = post.Name;

                //获取人员表当前选中岗位id的总人数
                var userids = userService.GetAll().Where(t => t.PostID == bId).Select(t => t.SysNO).ToList();
                foreach (var item in userids)
                {
                    cuserids = classUserService.GetAll().Where(t => t.ClassId == cId).Select(t => t.UserId).ToList();
                    if (!cuserids.Contains(item))
                    {
                        classUserService.CreateClassUser(new ClassUserEditDto {
                            ClassId = Convert.ToInt16(cId), UserId = item
                        });
                    }
                    //判断课程班级表有当前班级没用如果有要更新课程人员表保持一致和手机签到一样
                    var dto = cbtservic.GetAll().FirstOrDefault(t => t.BusinessId == cId && t.type == 2);
                    if (dto != null && dto.type != 4)
                    {
                        cpservic.CreateCourseBoundPersonnel(new CourseBoundPersonnelEditDto {
                            CourseId = dto.CourseId, AccountSysNo = item, CheckIN = false, IsBound = true
                        });
                    }
                }
            }
            cdjService.CreateClassDepJob(create);
        }