Example #1
0
        /// <summary>
        /// 修改字典类型数据
        /// </summary>
        public AjaxResult UpdateType(TbSysDictionaryType tbDic)
        {
            if (tbDic == null)
            {
                return(AjaxResult.Warning("参数错误"));
            }
            try
            {
                var any = Repository <TbSysDictionaryType> .Any(p => p.DictionaryCode == tbDic.DictionaryCode && p.id != tbDic.id);

                if (any)
                {
                    return(AjaxResult.Warning("分类编码'" + tbDic.DictionaryCode + "'重复!"));
                }
                any = Repository <TbSysDictionaryType> .Any(p => p.DictionaryType == tbDic.DictionaryType && p.id != tbDic.id);

                if (any)
                {
                    return(AjaxResult.Warning("分类名称'" + tbDic.DictionaryType + "'重复!"));
                }
                var model = MapperHelper.Map <TbSysDictionaryType, TbSysDictionaryType>(tbDic);
                var count = Repository <TbSysDictionaryType> .Update(model);

                if (count <= 0)
                {
                    return(AjaxResult.Error("数据错误,编辑失败!"));
                }
                return(AjaxResult.Success("修改成功"));
            }
            catch (Exception e)
            {
                var err = e.ToString();
                return(AjaxResult.Error("编辑失败!" + err));
            }
        }
 /// <summary>
 ///提交数据字典类型
 /// </summary>
 /// <param name="dicType"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public ActionResult SubmitFormType(TbSysDictionaryType dicType, string type)
 {
     if (type == "add")
     {
         var data = ddi.InsertType(dicType);
         return(Content(data.ToJson()));
     }
     else
     {
         var data = ddi.UpdateType(dicType);
         return(Content(data.ToJson()));
     }
 }