public void Edit(int id, FormCollection collection) { var msg = new Msg(); var Dorm = new Dorms(); var dorm = Dorm.FindById(id); try { if (dorm == null) { throw new Exception("该园区不存在"); } dorm.Dorm_nickname = collection["name"]; dorm.Dorm_note = collection["note"]; dorm.Dorm_is_active = Convert.ToBoolean(collection["is_active"]); dorm.Dorm_type = Convert.ToBoolean(Convert.ToInt32(collection["type"])); if (Dorm.Update(dorm)) { msg.Message = "保存成功!"; } else { throw new Exception("发生未知错误!"); } } catch (Exception ex) { msg.Code = -1; msg.Message = "保存失败:" + ex.Message; } Response.Write(msg.ToJson()); Response.End(); }
public void Delete(int id) { var msg = new Msg(); var User = new Dorms(); var user = User.FindById(id); try { if (user == null) { throw new Exception("该园区不存在!"); } else { if (User.Delete(id)) { msg.Message = "删除成功!"; } else { throw new Exception("发生未知错误,删除失败!"); } } } catch (Exception ex) { msg.Code = -1; msg.Message = ex.Message; } Response.Write(msg.ToJson()); Response.End(); }
public ActionResult Edit(int id) { var Dorm = new Dorms(); return(View(Dorm.FindById(id))); }