示例#1
0
        public void ModifyAcademicYear_Test()
        {
            AcademicYearInputModel testModel = new AcademicYearInputModel()
            {
                AcademicYearName = "测试AcademicYearName",
                Term             = "测试Term",
                InputStatus      = 82,
            };
            BaseResultModel <AcademicYearOutputModel> result = AcademicYearService.ModifyAcademicYear(testModel);

            Assert.IsTrue(result.IsSuccess, result.ErrorMessage);

            testModel = new AcademicYearInputModel()
            {
                AcademicYearID   = result.Data.AcademicYearID,
                AcademicYearName = "测试AcademicYearName",
            };
            result = AcademicYearService.ModifyAcademicYear(testModel);
            Assert.IsTrue(result.IsSuccess, result.ErrorMessage);

            BaseResultModel <int> delResult = AcademicYearService.DeleteAcademicYear(new List <Guid?>()
            {
                testModel.AcademicYearID
            });

            Assert.IsTrue(delResult.IsSuccess, delResult.ErrorMessage);
        }
        /// <summary>
        /// 新增、修改学年表
        /// </summary>
        /// <param name="model">OutputModel</param>
        /// <returns>OutputModel</returns>
        public BaseResultModel <AcademicYearOutputModel> ModifyAcademicYear(AcademicYearInputModel model)
        {
            if (model == null)
            {
                return(new ErrorResultModel <AcademicYearOutputModel>(EnumErrorCode.请求参数错误, "参数不能为空"));
            }
            ModelAttrEx arrtEx        = new ModelAttrEx();
            string      modelErrorMes = "";

            if (model.AcademicYearID.IsNullOrEmpty())
            {
                modelErrorMes += arrtEx.AddAttrVaild <AcademicYearInputModel>(ModelState, model);
            }
            else
            {
                modelErrorMes += arrtEx.EditAttrVaild <AcademicYearInputModel>(ModelState, model);
            }
            if (!modelErrorMes.IsNullOrEmpty())
            {
                return(new ErrorResultModel <AcademicYearOutputModel>(EnumErrorCode.请求参数错误, modelErrorMes));
            }
            return(AcademicYearService.ModifyAcademicYear(model));
        }