public ActionResult Add(UpdateCityModel model, int id = 0) { if (ModelState.IsValid) { var r = YunClient.Instance.Execute(new AddCityRequest { Ext = model.Ext, Name = model.Name, ParentId = model.ParentId, Sort = model.Sort, State = model.State }, Token); if (r.Result > 0) { TempData["success"] = "已成功添加"; return RedirectToAction("Index"); } TempData["error"] = "添加失败,错误代码:"+r.ErrMsg; } return View(model); }
public ActionResult Update(int id, UpdateCityModel model) { if (ModelState.IsValid) { var r = YunClient.Instance.Execute(new UpdateCityRequest { Ext = model.Ext, Id = id, Name = model.Name, Sort = model.Sort, State = model.State }, Token); if (r.Result) { TempData["success"] = "已成功修改"; return RedirectToAction("Index"); } TempData["error"] = "添加失败,错误代码:" + r.ErrMsg; } return View(model); }