public ActionResult CreateRole(CreateRoleData model) { if (ModelState.IsValid) { Roles.CreateRole(model.RoleToCreate); return(new RedirectResult(RedirectUrl)); } return(View("Index", GenerateModel(model))); }
public ActionResult CreateRole(CreateRoleData model) { if (ModelState.IsValid) { Roles.CreateRole(model.RoleToCreate); Response.Redirect(RedirectUrl); } return(PartialView(model)); }
/// <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 })); } }
/// <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)); }
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)); }