コード例 #1
0
        public ActionResult Create([FromForm] SystemRoleCreate ReqModel)
        {
            // TODO: Add insert logic here
            if (SystemRoleHelper.Exists(p => p.Name.Equals(ReqModel.RoleName)))
            {
                return(Json(ResponseHelper.Error("该角色名已经存在!")));
            }
            var systemRole = new SystemRole
            {
                CreatedTime = DateTime.Now,
                Name        = ReqModel.RoleName,
                Remark      = ReqModel.Remark
            };

            SystemRoleHelper.Insert(systemRole);
            return(Json(ResponseHelper.Success("ok")));
        }
コード例 #2
0
        public ActionResult Edit([FromForm] SystemRoleEdit ReqModel)
        {
            var role = SystemRoleHelper.GetModel(p => p.Id == ReqModel.Id);

            if (role == null)
            {
                return(new RedirectResult("/home/errormsg?msg=" + WebUtility.UrlEncode("未找到该角色")));
            }
            if (SystemRoleHelper.Exists(p => p.Id != role.Id && p.Name.Equals(ReqModel.RoleName)))
            {
                return(Json(ResponseHelper.Error("该角色名已经存在!")));
            }
            role.Name   = ReqModel.RoleName;
            role.Remark = ReqModel.Remark;
            SystemRoleHelper.Update(role, SystemRoleHelper.Columns.Name, SystemRoleHelper.Columns.Remark);
            return(Json(ResponseHelper.Success("ok")));
        }