Exemplo n.º 1
0
        /// <summary>
        /// 修改功能信息
        /// </summary>
        /// <param name="id">功能ID</param>
        /// <param name="fun">功能实体数据</param>
        /// <returns>Result</returns>
        public Result <object> editFun(string id, Function fun)
        {
            if (!verify("editFun"))
            {
                return(result);
            }

            if (fun == null)
            {
                return(result.badRequest());
            }

            var data = DbHelper.find <Function>(id);

            if (data == null)
            {
                return(result.notFound());
            }

            data.navigatorId = fun.navigatorId;
            data.index       = fun.index;
            data.name        = fun.name;
            data.alias       = fun.alias;
            data.routes      = fun.routes;
            data.url         = fun.url;
            data.iconurl     = fun.iconurl;
            data.icon        = fun.icon;
            data.remark      = fun.remark;
            data.isBegin     = fun.isBegin;
            data.isShowText  = fun.isShowText;
            data.isVisible   = fun.isVisible;

            return(DbHelper.update(data) ? result.success() : result.dataBaseError());
        }
Exemplo n.º 2
0
 /// <summary>
 /// 功能是否已存在
 /// </summary>
 /// <param name="fun">功能实体数据</param>
 /// <returns>bool 是否已存在</returns>
 private static bool existed(Function fun)
 {
     using (var context = new Entities())
     {
         return(context.functions.Any(i =>
                                      i.id != fun.id && i.navigatorId == fun.navigatorId && i.name == fun.name));
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 新增功能信息
        /// </summary>
        /// <param name="fun">功能实体数据</param>
        /// <returns>Result</returns>
        public Result <object> addFun(Function fun)
        {
            if (!verify("newFun"))
            {
                return(result);
            }

            if (fun == null)
            {
                return(result.badRequest());
            }

            if (existed(fun))
            {
                return(result.dataAlreadyExists());
            }

            fun.id         = Util.newId();
            fun.isVisible  = true;
            fun.creatorId  = userId;
            fun.createTime = DateTime.Now;

            return(DbHelper.insert(fun) ? result.created(fun) : result.dataBaseError());
        }