public ActionResult NewCountry() { //创建空的Model CountryViewModel model = new CountryViewModel(); return View(model); }
public ActionResult NewCountry(CountryViewModel model) { if (ModelState.IsValid) { //创建数据 Country data = new Country(); data.Name = model.Name; data.Remark = model.Remark ?? string.Empty; //保存数据 string strErrText; DDSystem country = new DDSystem(); if (country.InsertCountry(data, LoginAccountId, LoginStaffName, out strErrText)) { return Json(string.Empty); } else { return Json(strErrText); } } return View(model); }
public ActionResult ModifyCountry(string id) { string strErrText; //生成Model数据 DDSystem country = new DDSystem(); Country data = country.LoadCountry(long.Parse(id), LoginAccountId, LoginStaffName, out strErrText); if (data == null) { throw new Exception(strErrText); } CountryViewModel model = new CountryViewModel(); model.Id = data.Id; model.Name = data.Name; model.Remark = data.Remark; return View(model); }