public ActionResult CourseDetailt(int id, int tc)
        {
            var resultCoreInfo = _coreInfoService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = id
            });

            resultCoreInfo.IsTypeC = tc;
            return(View(resultCoreInfo));
        }
        public ActionResult CourseDetail(int courseId)
        {
            CourseViewModel vm = new CourseViewModel();
            //课程
            CourseInfoListDto courseInfo = _courseInfoAppService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = courseId
            });

            courseInfo.Content = System.Web.HttpUtility.HtmlDecode(courseInfo.Content);
            //内训师
            int teacherId = courseInfo.TeacherId;
            var teacher   = _teachersAppService.GetTeachersById(new EntityDto <long>()
            {
                Id = teacherId
            });
            int userId = int.Parse(CookieHelper.GetCookieValue("UserId").ToString());

            //是否已报名
            var boundData = _courseBoundPersonnelAppService.GetCourseBoundByUserIdOrCourseId(userId, courseId);//绑定数据

            if (boundData != null)
            {
                vm.IsSingleUp = true;
            }
            else
            {
                vm.IsSingleUp = false;
            }
            if (courseInfo.Status == 4)
            {
                vm.IsComplete = true;
            }
            else
            {
                vm.IsComplete = false;
            }
            vm.teacher    = teacher;
            vm.CourseInfo = courseInfo;
            vm.CourseId   = courseId;
            return(View(vm));
        }
Пример #3
0
        public ActionResult SetBoundCourseByType(int courseId, int typeId, int typeCaseId)
        {
            var result = new resultData();

            result.status = "-1";
            var courseDate = courseInfoService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = courseId
            });                                                                                           //课程数据

            if (courseDate.Status != (int)CourseStatus.Pending)
            {
                return(Content(Serialize(new resultData()
                {
                    status = "-2", msg = "当前课程状态为:待审核,才能添加人员"
                })));
            }

            if (typeId == (int)ConfigureType.Class && courseDate != null &&
                courseDate.Status != (int)CourseStatus.Completed && typeCaseId > 0)
            {
                var configure           = configureTypeService.GetCTypeByClassIdOrType(typeCaseId, typeId); //班级的数据
                var configureByCourseId = configureTypeService.GetCTypeByCourseIdOrType(courseId, typeId);  //课程和班级数量

                if ((configure != null && configure.Count > 0) || (configureByCourseId != null && configureByCourseId.Count > 0))
                {
                    return(Content(Serialize(new resultData()
                    {
                        status = "-1", msg = "班级和课程只能关联一次,不允许添加"
                    })));
                }
            }

            if (courseDate != null && typeId >= 0 && typeCaseId > 0)
            {
                var create    = new CourseBoundConfigureTypeEditDto();                                                   //实例化对象Bound对象
                var boundData = configureTypeService.GetCTypeByCourseIdOrTypeId((int)courseDate.Id, typeId, typeCaseId); //绑定的数据
                if (boundData == null)                                                                                   //如果没就增加
                {
                    create.CourseId   = (int)courseDate.Id;
                    create.CourseName = courseDate.CourseName;
                    create.type       = typeId;
                    switch (typeId)//类型
                    {
                    case (int)ConfigureType.Department:
                        #region 部门操作
                        var department = departmentService.GetAllDepartmentInfos().FirstOrDefault(v => v.DepartmentId == typeCaseId);    //获取部门唯一数据
                        if (department != null)
                        {
                            var createDataDUser = cbPersonnelService.GetUserDateByDepartment((int)courseDate.Id, department);
                            foreach (var itemD in createDataDUser)    //循环遍历插入
                            {
                                CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto();
                                cbp.CourseId        = (int)courseDate.Id;
                                cbp.CourseName      = courseDate.CourseName;
                                cbp.AccountSysNo    = itemD.SysNO;
                                cbp.AccountUserName = itemD.DisplayName;
                                cbPersonnelService.CreateCourseBoundPersonnel(cbp);
                            }

                            create.BusinessId   = department.DepartmentId;
                            create.BusinessName = department.DisplayName;
                        }
                        #endregion
                        break;

                    case (int)ConfigureType.Post:
                        #region 岗位操作
                        var post = jobService.GetJobPostById(new EntityDto <long>()
                        {
                            Id = typeCaseId
                        });                                                                                 //获取唯一岗位
                        if (post != null)
                        {
                            var creatDataPUser = cbPersonnelService.GetUserDateByJobPost((int)courseDate.Id, post);
                            foreach (var itemP in creatDataPUser)    //循环遍历插入
                            {
                                CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto();
                                cbp.CourseId        = (int)courseDate.Id;
                                cbp.CourseName      = courseDate.CourseName;
                                cbp.AccountSysNo    = itemP.SysNO;
                                cbp.AccountUserName = itemP.DisplayName;
                                cbPersonnelService.CreateCourseBoundPersonnel(cbp);
                            }
                            create.BusinessId   = (int)post.Id;
                            create.BusinessName = post.Name;
                        }
                        #endregion
                        break;

                    case (int)ConfigureType.Class:
                        #region 班级操作
                        var classes = classService.GetClassesInfoById(new EntityDto <long>()
                        {
                            Id = typeCaseId
                        });                                                                                          //获取唯一课程数据
                        if (classes != null)
                        {
                            var creatUserDate = cbPersonnelService.GetUserDateByClasses((int)courseDate.Id, classes);
                            foreach (var itemC in creatUserDate)    //循环遍历插入
                            {
                                CourseBoundPersonnelEditDto cbp = new CourseBoundPersonnelEditDto();
                                cbp.CourseId        = (int)courseDate.Id;
                                cbp.CourseName      = courseDate.CourseName;
                                cbp.AccountSysNo    = itemC.SysNO;
                                cbp.AccountUserName = itemC.DisplayName;
                                cbPersonnelService.CreateCourseBoundPersonnel(cbp);
                            }
                            create.BusinessId   = (int)classes.Id;
                            create.BusinessName = classes.ClassesName;
                        }
                        #endregion
                        break;

                    default:

                        break;
                    }

                    configureTypeService.CreateCourseBoundConfigureType(create);
                    result.msg = "";
                }
                else
                {
                    result.msg = boundData.BusinessName;
                }
                result.status = "0";
            }
            return(Content(Serialize(result)));
        }
        public ActionResult SetBoundCourseByUser(int courseId, string userIds)
        {
            var result = new resultData();

            result.status = "-1";
            var userListId = userIds.Split(',').ToList();//用户的Id
            var list       = new List <string>();
            var listLraen  = new List <string>();
            var courseDate = courseInfoService.GetCourseInfoById(new EntityDto <long>()
            {
                Id = courseId
            });                                                                                           //课程数据

            if (courseDate != null && userListId != null && userListId.Any())
            {
                if (courseDate.Status != (int)CourseStatus.Pending)
                {
                    return(Content(Serialize(new resultData()
                    {
                        status = "-1", msg = "当前课程状态为:待审核,才能添加人员"
                    })));
                }
                foreach (var id in userListId)
                {
                    var userData = userAccountService.GetUserAccountById(new EntityDto <long>()
                    {
                        Id = Convert.ToInt32(id)
                    });                                                                                                                  //用户数据
                    var boundData = courseBoundService.GetCourseBoundByUserIdOrCourseId(userData.SysNO, Convert.ToInt32(courseDate.Id)); //绑定数据
                    if (boundData == null)                                                                                               //如果没就增加
                    {
                        //增加人员
                        var create = new CourseBoundPersonnelEditDto();
                        create.AccountSysNo    = userData.SysNO;
                        create.AccountUserName = userData.DisplayName;
                        create.CourseId        = Convert.ToInt32(courseDate.Id);
                        create.CourseName      = courseDate.CourseName;
                        courseBoundService.CreateCourseBoundPersonnel(create);
                    }
                    else
                    {
                        list.Add(userData.DisplayName);
                    }

                    var configu = configureTypeService.GetCTypeByCIdOrType((int)courseDate.Id, (int)ConfigureType.Personal, userData.SysNO);
                    //增加关系
                    if (configu == null)
                    {
                        var createConfigure = new CourseBoundConfigureTypeEditDto();
                        createConfigure.CourseId     = (int)courseDate.Id;
                        createConfigure.CourseName   = courseDate.CourseName;
                        createConfigure.type         = (int)ConfigureType.Personal;
                        createConfigure.BusinessId   = userData.SysNO;
                        createConfigure.BusinessName = userData.DisplayName;
                        configureTypeService.CreateCourseBoundConfigureType(createConfigure);
                    }
                }
                result.status = "0";
                result.msg    = string.Join(",", list);
            }
            return(Content(Serialize(result)));
        }