Exemplo n.º 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());
        }
Exemplo n.º 2
0
        public ActionResult ClassesManageCreate(int cId = 0)
        {
            var model = new GetClassesInfoForEditOutput();

            if (cId > 0)
            {
                model = classesinfoService.GetClassesInfoForEdit(new NullableIdDto <long> {
                    Id = cId
                });
            }
            return(View("ClassesManage/Create", model.ClassesInfo));
        }
        /// <summary>
        /// 班级数量加1
        /// </summary>
        private void SetCourseCount(int classId)
        {
            var classed = classInfolService.GetClassesInfoForEdit(new NullableIdDto <long>()
            {
                Id = classId
            });

            if (classed != null)
            {
                var date = _courseBoundConfigureTypeRepository.GetAll()
                           .Where(c => c.type == (int)ConfigureType.Class && c.BusinessId == classed.ClassesInfo.Id);
                classed.ClassesInfo.CourseCount += date.Count();
                classInfolService.UpdateClassesInfoAsync(classed.ClassesInfo);
            }
        }
        public ActionResult CheckIn(int CourseId)
        {
            int    uId      = int.Parse(CookieHelper.GetCookieValue("UserId").ToString());
            string UserName = CookieHelper.GetCookieValue("DisplayName").ToString();
            var    dto      = courseBoundService.GetCourseBoundUserByCourseId(CourseId).FirstOrDefault(t => t.AccountSysNo == uId).MapTo <CourseBoundPersonnelEditDto>();

            ViewBag.Stauts = 0;
            if (dto != null)
            {
                if (dto.CheckIN == true)
                {
                    ViewBag.Stauts = 1;
                }
                else
                {
                    dto.CheckIN = true;
                    courseBoundService.UpdateCourseBoundPersonnel(dto);
                    //更新课程表签到人数
                    var cdto = courseService.GetCourseInfoEditById(new EntityDto <long> {
                        Id = dto.CourseId
                    });
                    cdto.CheckinNum++;
                    courseService.UpdateCourseInfo(cdto);
                    ViewBag.Stauts = 2;
                }
            }
            else//不是已绑定到课程的人员
            {
                courseBoundService.CreateCourseBoundPersonnel(new CourseBoundPersonnelEditDto {
                    CourseId = CourseId, AccountSysNo = uId, CheckIN = true, IsBound = false, AccountUserName = UserName
                });
                ViewBag.Stauts = 2;
            }
            //查到线下培训课程所对就的班级
            var configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrByType(CourseId, (int)ConfigureType.Class);

            if (configu != null)
            {
                //班级人员关联关系数据添加
                var classUser = new ClassUserEditDto();
                classUser.ClassId = configu.BusinessId;
                classUser.UserId  = uId;
                classuserService.CreateClassUser(classUser);
                //把人员添加到班级中
                var classInfo = _classesInfoAppService.GetClassesInfoForEdit(new NullableIdDto <long>()
                {
                    Id = configu.BusinessId
                });
                classInfo.ClassesInfo.MemberCount++;
                _classesInfoAppService.UpdateClassesInfoAsync(classInfo.ClassesInfo);
            }
            return(View());
        }
        public JsonResult SingleUpCourse(int courseId)
        {
            //课程对像
            var courseDate = _courseInfoAppService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = courseId
            });                                                                                               //课程数据

            if (courseDate != null)
            {
                int userId    = int.Parse(CookieHelper.GetCookieValue("UserId").ToString());
                var user      = _userAccountService.GetUserAccountBySysNo(userId);                                                            //查询用户数据
                var boundData = _courseBoundPersonnelAppService.GetCourseBoundByUserIdOrCourseId(user.SysNO, Convert.ToInt32(courseDate.Id)); //绑定数据
                if (boundData == null)
                {
                    //增加人员
                    var create = new CourseBoundPersonnelEditDto();
                    create.AccountSysNo    = user.SysNO;
                    create.AccountUserName = user.DisplayName;
                    create.CourseId        = Convert.ToInt32(courseDate.Id);
                    create.CourseName      = courseDate.CourseName;
                    _courseBoundPersonnelAppService.CreateCourseBoundPersonnel(create);
                }


                var configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrType((int)courseDate.Id, (int)ConfigureType.Personal, user.SysNO);
                //增加关系
                if (configu == null)
                {
                    var createConfigure = new CourseBoundConfigureTypeEditDto();
                    createConfigure.CourseId     = (int)courseDate.Id;
                    createConfigure.CourseName   = courseDate.CourseName;
                    createConfigure.type         = (int)ConfigureType.Personal;
                    createConfigure.BusinessId   = user.SysNO;
                    createConfigure.BusinessName = user.DisplayName;
                    _courseBoundConfigureTypeAppService.CreateCourseBoundConfigureType(createConfigure);
                }
                //如果是线个考试则把人员配置到班级中
                if (courseDate.Type == 4)
                {
                    //查到线下培训课程所对就的班级
                    configu = _courseBoundConfigureTypeAppService.GetCTypeByCIdOrByType((int)courseDate.Id, (int)ConfigureType.Class);
                    if (configu != null)
                    {
                        //班级人员关联关系数据添加
                        var classUser = new ClassUserEditDto();
                        classUser.ClassId = configu.BusinessId;
                        classUser.UserId  = userId;
                        _classUserAppService.CreateClassUser(classUser);
                        //把人员添加到班级中
                        var classInfo = _classesInfoAppService.GetClassesInfoForEdit(new NullableIdDto <long>()
                        {
                            Id = configu.BusinessId
                        });
                        classInfo.ClassesInfo.MemberCount++;
                        _classesInfoAppService.UpdateClassesInfoAsync(classInfo.ClassesInfo);
                    }
                }
            }
            return(Json(courseDate, JsonRequestBehavior.AllowGet));
        }