コード例 #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));
        }
        /// <summary>
        /// 通过Id获取班级项目信息进行编辑或修改
        /// </summary>
        public async Task <GetClassTrainingInfoForEditOutput> GetClassTrainingInfoForEditAsync(NullableIdDto <long> input)
        {
            var output = new GetClassTrainingInfoForEditOutput();

            ClassTrainingInfoEditDto EditDto;

            if (input.Id.HasValue)
            {
                var entity = await _ClassTrainingInfoRepository.GetAsync(input.Id.Value);

                EditDto = entity.MapTo <ClassTrainingInfoEditDto>();
            }
            else
            {
                EditDto = new ClassTrainingInfoEditDto();
            }

            output.ClassTrainingInfoEditDto = EditDto;
            return(output);
        }