コード例 #1
0
        public ActionResult CreateRole(CreateRoleData model)
        {
            if (ModelState.IsValid)
            {
                Roles.CreateRole(model.RoleToCreate);
                return(new RedirectResult(RedirectUrl));
            }

            return(View("Index", GenerateModel(model)));
        }
コード例 #2
0
        public ActionResult CreateRole(CreateRoleData model)
        {
            if (ModelState.IsValid)
            {
                Roles.CreateRole(model.RoleToCreate);
                Response.Redirect(RedirectUrl);
            }

            return(PartialView(model));
        }
コード例 #3
0
ファイル: Create.cs プロジェクト: jetoneDev/jt-og
 /// <summary>
 /// 新增公司系统角色,去除token
 /// </summary>
 /// <param name="data"></param>
 /// <param name="companyId"></param>
 /// <param name="systemId"></param>
 /// <returns></returns>
 public static int CreateRole(CreateRoleData data, int companyId, int systemId)
 {
     if (data == null)
     {
         throw new ArgumentException("data 参数不能为空");
     }
     using (var c = Sql.CreateConnection())
     {
         return(c.SelectScalar <int>(Sql.CreateRoleData, new { companyId, systemId, data.RoleName }));
     }
 }
コード例 #4
0
ファイル: Create.cs プロジェクト: jetoneDev/jt-og
        /// <summary>
        /// 新增公司系统角色
        /// </summary>
        /// <param name="data"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static int CreateRole(CreateRoleData data, string token)
        {
            if (string.IsNullOrWhiteSpace(token))
            {
                throw new ArgumentException("token不能为空");
            }
            var tokenData = DisassembleProtocol(token);
            var companyId = Convert.ToInt32(tokenData["CompanyId"]);
            var systemId  = Convert.ToInt32(tokenData["SystemId"]);

            return(CreateRole(data, companyId, systemId));
        }
コード例 #5
0
        private Tuple <CreateRoleData, DeleteRoleData, UserRoleData> GenerateModel(CreateRoleData item1 = null)
        {
            var roles     = Roles.GetAllRoles();
            var usernames = Database.Open("ContactMessageDatabase").Query("SELECT Email FROM UserProfile")
                            .Select(r => r.Email).Cast <string>();

            var createData = item1 ?? new CreateRoleData();
            var deleteData = new DeleteRoleData {
                Roles = roles
            };
            var userRole = new UserRoleData {
                Roles = roles, UserNames = usernames
            };

            return(Tuple.Create(createData, deleteData, userRole));
        }