public string deleteMajorById(string id) { try { MajorDao majorDao = new MajorDao(); int res = majorDao.deleteMajorById(int.Parse(id)); if (res == 1) { return("success"); } else { return("fail:不存在该专业"); } }catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("fail:" + e.Message); } }
public void TestMajorMethod_major_add_get_delete() { MajorDao majorDao = new MajorDao(); Major major = new Major(); // major.id = "a323456"; major.name = "英语"; major.remark = "123sdaSDSA"; // majorDao.addMajor(major); major = majorDao.getMajorById(major.id); ValidResult validResult = ValidateHelper.IsValid(major); Assert.AreEqual(1, majorDao.deleteMajorById(major.id)); if (!validResult.IsVaild) { foreach (ErrorMember errorMember in validResult.ErrorMembers) { Debug.WriteLine(errorMember.ErrorMemberName + ":" + errorMember.ErrorMessage); } } }