/// <summary> /// 根据Id获取 /// </summary> /// <param name="Id"></param> /// <returns></returns> public DictionaryClassType GetById(int Id) { DictionaryClassType obj = NSession.Get <DictionaryClassType>(Id); if (obj == null) { throw new Exception("返回实体为空"); } else { return(obj); } }
public JsonResult Create(DictionaryClassType obj) { try { NSession.SaveOrUpdate(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public JsonResult DeleteConfirmed(int id) { try { DictionaryClassType obj = GetById(id); NSession.Delete(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public ActionResult Edit(DictionaryClassType obj) { try { DictionaryClassType c = GetById(obj.Id); NSession.CreateSQLQuery("update Dictionarys set DicCode='" + obj.Code + "' where DicCode='" + c.Code + "' ") .UniqueResult(); NSession.Clear(); NSession.Update(obj); NSession.Flush(); } catch (Exception ee) { return(Json(new { IsSuccess = false, ErrorMsg = "出错了" })); } return(Json(new { IsSuccess = true })); }
public ActionResult Edit(int id) { DictionaryClassType obj = GetById(id); return(View(obj)); }