Beispiel #1
0
        public string SaveFunction(string json)
        {
            using (var db = new NCtecanEntities())
            {
                sys_function m   = new sys_function();
                JsonObject   obj = new JsonObject(json);
                decimal      fid = decimal.Parse(obj["id"].Value);
                if (obj["id"].Value != "0")
                {
                    m = db.sys_function.FirstOrDefault(ss => ss.fid == fid);
                }
                m.pid          = int.Parse(obj["pid"].Value);
                m.title        = obj["name"].Value;
                m.function     = obj["funname"].Value;
                m.control      = obj["control"].Value;
                m.functionname = obj["functionname"].Value;
                m.parameters   = obj["parameters"].Value;
                m.url          = obj["comment"].Value;
                if (obj["id"].Value == "0")
                {
                    db.sys_function.Add(m);
                }

                if (db.SaveChanges() > 0)
                {
                    return(GetFunctionTree());
                }
                else
                {
                    return("failed");
                }
            }
        }
 public IActionResult AddSave(sys_function vmodel)
 {
     if (vmodel != null)
     {
         if (string.IsNullOrEmpty(vmodel.Function_ID))
         {
             if (string.IsNullOrEmpty(vmodel.Function_Name))
             {
                 return(Json(new { code = 100, msg = "请输入功能名" }));
             }
             vmodel.Function_ID         = Guid.NewGuid().ToString();
             vmodel.Function_CreateTime = DateTime.Now;
             _Sys_FunctionService.Insert(vmodel);
         }
         else
         {
             return(Json(new { code = 100, msg = "无效参数" }));
         }
     }
     else
     {
         return(Json(new { code = 100, msg = "无效参数" }));
     }
     return(Json(new { code = 200, msg = "操作成功" }));
 }
Beispiel #3
0
 public IActionResult Save(sys_function vmodel)
 {
     if (vmodel != null)
     {
         if (string.IsNullOrEmpty(vmodel.Function_Name))
         {
             throw new MessageBox("请输入功能名");
         }
         if (string.IsNullOrEmpty(vmodel.Function_ID))
         {
             vmodel.Function_ID         = Guid.NewGuid().ToString();
             vmodel.Function_CreateTime = DateTime.Now;
             _Sys_FunctionService.Insert(vmodel);
         }
         else
         {
             _Sys_FunctionService.Update(vmodel);
         }
     }
     else
     {
         return(Json(new { status = 0, msg = "无效参数" }));
     }
     return(Json(new { status = 1, msg = "操作成功" }));
 }
        public IActionResult Post([FromBody] sys_function value)
        {
            var oldSysFunction = _sysFunctionRpt.FindBy(f => f.FunctionName == value.FunctionName);

            if (oldSysFunction.Any())
            {
                return(BadRequest(string.Concat(value.FunctionName, "已经存在。")));
            }
            value.CreatedAt = DateTime.Now;
            value.UpdatedAt = DateTime.Now;
            _sysFunctionRpt.Add(value);
            _sysFunctionRpt.Commit();
            return(new OkObjectResult(value));
        }
        public IActionResult Delete(int id)
        {
            sys_function sysFunction = _sysFunctionRpt.GetSingle(id);

            if (sysFunction == null)
            {
                return(new NotFoundResult());
            }
            _sysRoleFunctionRpt.DeleteWhere(f => f.FunctionId == id);
            _sysRoleFunctionRpt.Commit();
            _sysFunctionRpt.Delete(sysFunction);
            _sysFunctionRpt.Commit();

            return(new NoContentResult());
        }
 public IActionResult EditSave(sys_function vmodel)
 {
     if (!string.IsNullOrEmpty(vmodel.Function_ID))
     {
         if (string.IsNullOrEmpty(vmodel.Function_Name))
         {
             return(Json(new { code = 100, msg = "请输入功能名" }));
         }
         var model = _Sys_FunctionService.FindByClause(p => p.Function_ID == vmodel.Function_ID);
         if (model != null)
         {
             _Sys_FunctionService.UpdateWhere(model, p => new { p.Function_Num, p.Function_Name, p.Function_ByName }, p => p.Function_ID == vmodel.Function_ID);
         }
         else
         {
             return(Json(new { code = 100, msg = "没有该功能" }));
         }
     }
     else
     {
         return(Json(new { code = 100, msg = "参数无效" }));
     }
     return(Json(new { code = 200, msg = "操作成功" }));
 }
Beispiel #7
0
 /// <summary>
 /// 删除数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public bool Delete(sys_function entity)
 {
     return(_Sys_FunctionRepositoryS.Delete(entity));
 }
Beispiel #8
0
 /// <summary>
 /// 更新实体数据
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="updateColumns">修改字段表达式树</param>
 /// <returns></returns>
 public bool Update(sys_function entity, Expression <Func <sys_function, object> > updateColumns)
 {
     return(_Sys_FunctionRepositoryS.Update(entity, updateColumns));
 }
Beispiel #9
0
 /// <summary>
 /// 更新实体数据
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public bool Update(sys_function entity)
 {
     return(_Sys_FunctionRepositoryS.Update(entity));
 }
Beispiel #10
0
 /// <summary>
 /// 写入实体数据
 /// </summary>
 /// <param name="entity">实体类</param>
 /// <returns></returns>
 public long Insert(sys_function entity)
 {
     return(_Sys_FunctionRepositoryS.Insert(entity));
 }