public void TestMajorMethod_major_listAll_changeName() { MajorDao majorDao = new MajorDao(); List <Major> majors = majorDao.listAllByMajor(); foreach (var major in majors) { Console.WriteLine(major.id); } string name = "地理"; Assert.AreEqual(1, majorDao.changeNameById(majors[0].id, name)); }
public string editMajor(string id, string name) { try { MajorDao majorDao = new MajorDao(); int res = majorDao.changeNameById(int.Parse(id), name); if (res == 1) { return("success"); } else { return("fail:不存在该专业"); } } catch (Exception e) { LogUtil.writeLogToFile(e, Request); return("fail:" + e.Message); } }