Пример #1
0
        public async Task <ActionResult> ClassesProjectForm(int id = 0)
        {
            var model = new GetClassTrainingInfoForEditOutput();

            if (id > 0)
            {
                model = await classprojectService.GetClassTrainingInfoForEditAsync(new NullableIdDto <long> {
                    Id = id
                });
            }
            var typeId = model.ClassTrainingInfoEditDto == null ? 1 : model.ClassTrainingInfoEditDto.TypeId;

            //培训类型(1 - 课程、2 - 考试、3 - 问卷、4 - 线下培训)
            ViewBag.typeSel = new List <SelectListItem> {
                //new SelectListItem { Text = "课程", Value = "1" ,Selected= typeId==1},
                new SelectListItem {
                    Text = "考试", Value = "2", Selected = typeId == 2
                },
                new SelectListItem {
                    Text = "问卷", Value = "3", Selected = typeId == 3
                },
                //new SelectListItem { Text = "线下培训", Value = "4",Selected= typeId==4}
            };
            var prolist = courseservic.GetAll().Where(t => t.Type == typeId).ToList();
            var prosel  = new List <SelectListItem>();

            prolist.ForEach(t => prosel.Add(new SelectListItem {
                Text = t.CourseName, Value = t.Id + ""
            }));
            ViewBag.proSel = prosel;
            return(View("ClassesProject/Form", model.ClassTrainingInfoEditDto));
        }
Пример #2
0
        public ActionResult Delete(int id)
        {
            try
            {
                var model = _corecategoryService.GetCourseCategoryList().Where(t => t.CategoryId == id).FirstOrDefault();
                if (model == null)
                {
                    return(Json(new { code = 200, msg = "删除成功!" }, JsonRequestBehavior.AllowGet));
                }

                if (model != null)
                {
                    var courseDate = _courseInfoService.GetAll().Where(c => c.CategoryType == model.CategoryId);
                    return(Json(new { code = 500, msg = "删除失败,课程正在使用当前分类,不允许删除" }, JsonRequestBehavior.AllowGet));
                }

                _corecategoryService.DeleteCourseCategorybyCategoryId(model.CategoryId);
                return(Json(new { code = 200, msg = "删除成功!" }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(new { code = 500, msg = "删除失败!" }, JsonRequestBehavior.AllowGet));
            }
        }