public JsonResult SaveDic(SysDicInfo model) { bool result = false; if (model.Id == Guid.Empty) { result = InfosContract.AddDic(model); } else { result = InfosContract.EditDic(model); } return(Json(new { success = result })); }
/// <summary> /// 添加字典 /// </summary> /// <param name="sr"></param> /// <returns></returns> public bool AddDic(SysDicInfo dic) { try { dic.Id = CombHelper.NewComb(); dic.CreatedTime = DateTime.Now; if (dic.DicParentID == null) { dic.DicParentID = Guid.Empty; } SysDicInfoRepository.Insert(dic); return(true); } catch (Exception ex) { return(false); } }
/// <summary> /// 修改一个字典 /// </summary> /// <param name="dic"></param> /// <returns></returns> public bool EditDic(SysDicInfo dic) { try { SysDicInfo old_Dic = SysDicInfo.FirstOrDefault(d => d.Id == dic.Id); old_Dic.DicCode = dic.DicCode; old_Dic.DicName = dic.DicName; old_Dic.DicParentID = dic.DicParentID; old_Dic.DicLevel = dic.DicLevel; old_Dic.DicType = dic.DicType; old_Dic.DicValue = dic.DicValue; old_Dic.Remark = dic.Remark; old_Dic.DicSetValue = dic.DicSetValue; SysDicInfoRepository.Update(old_Dic); return(true); } catch (Exception ex) { return(false); } }