Example #1
0
        public async Task <IActionResult> FuncDetail(string id, RBAC.Func model, int moduleId = 0)
        {
            var now = DateTime.Now;

            var result = new Result();

            if (model.Name.IsNullOrEmpty())
            {
                result.Error("请输入名称");
                return(Json(result));
            }

            if (!id.IsEmpty() && moduleId == 0)
            {
                var old = DefaultStorage.FuncGet(id);
                if (old == null)
                {
                    result.Error("数据不存在");
                    return(Json(result));
                }

                var status = await TryUpdateModelAsync(old);

                if (status)
                {
                    result.Status = DefaultStorage.FuncUpdate(old);
                    if (!result.Status)
                    {
                        result.Error("更新失败");
                        return(Json(result));
                    }
                }
                else
                {
                    result.Error("参数有误");
                    return(Json(result));
                }
                return(Json(result));
            }

            if (id.IsEmpty() && moduleId == 0)
            {
                result.Message = "参数错误";
                return(Json(result));
            }

            model.Mid = moduleId;

            result.Status = DefaultStorage.FuncCreate(model);
            if (!result)
            {
                result.Error("添加失败");
                return(Json(result));
            }
            return(Json(result));
        }
Example #2
0
        public IActionResult FuncDetail(string id, int moduleId)
        {
            var data = new RBAC.Func();

            var model = new Model <RBAC.Func, int>(data, moduleId);

            if (!id.IsEmpty())
            {
                model.Data = DefaultStorage.FuncGet(id);
            }
            return(PartialView(model));
        }