示例#1
0
        public ActionResult add(int id, sysFunctionView model)
        {
            try
            {
                //1.0 判断视图的合法性
                if (ModelState.IsValid == false)
                {
                    return(WriteError("实体验证失败"));
                }

                //2.0 将model中的Mid补全
                model.mID         = id;
                model.fCreateTime = DateTime.Now;
                model.fUpdateTime = DateTime.Now;
                model.fCreatorID  = UserMgr.GetCurrentUserInfo().uID;

                //3.0 实体转换和保存
                var entity = model.EntityMap();
                funSer.Add(entity);
                funSer.SaveChanges();

                return(WriteSuccess("新增成功"));
            }
            catch (Exception ex)
            {
                return(WriteError(ex));
            }
        }
示例#2
0
 public ActionResult edit(int id, sysFunctionView model)
 {
     try
     {
         if (ModelState.IsValid == false)
         {
             return(WriteError("实体验证失败"));
         }
         //1.0将model中的kid不全
         model.mID = id;
         sysFunction entity = model.EntityMap();
         _funSer.Edit(entity, new string[]
         {
             "mParentID",
             "mName",
             "mID"
         });
         _funSer.SaveChanges();
         return(WriteSuccess("数据编辑成功"));
     }
     catch (Exception ex)
     {
         return(WriteError(ex));
     }
 }