public async Task <IActionResult> Add(long tid, string returnUrl, CancellationToken cancellationToken) { var model = new RoleAddModel { TeamId = tid, UserEmail = string.Empty, ClaimType = Identity.Constants.ClaimType.PlaysInTeam, ReturnUrl = Url.IsLocalUrl(returnUrl) ? returnUrl : _defaultReturnUrl }; if (!(await _authorizationService.AuthorizeAsync(User, new TeamEntity(model.TeamId), Authorization.TeamOperations.AddTeamMember)).Succeeded) { return(JsonAjaxRedirectForModal(Url.Action(nameof(Error.AccessDenied), nameof(Error), new { model.ReturnUrl }))); } return(PartialView(ViewNames.Role._AddMemberModalPartial, model)); }
public ActionResult AddRole(RoleAddModel roleAddModel) { if (!ModelState.IsValid) { string msg = Web.Common.WebCommonHelper.GetValidMsg(ModelState); return(Json(new AjaxResult() { Status = "error", Msg = msg })); } //todo 检查角色名是否重复 long roleId = roleService.AddNewRole(roleAddModel.Name); permService.AddPermIds(roleId, roleAddModel.PermIds); return(Json(new AjaxResult() { Status = "ok" })); }
public ActionResult Add(RoleAddModel model) { //ModelState.IsValid检查model验证是否通过 if (!ModelState.IsValid) { return(Json(new AjaxResult { Status = "error", ErrorMsg = MVCHelper.GetValidMsg(ModelState) })); } //TransactionScope(事务) long roleId = roleService.AddNew(model.Name); permService.AddPermIds(roleId, model.PermissionIds); return(Json(new AjaxResult { Status = "ok" })); }
public async Task <IActionResult> AddRole(RoleAddModel addModel) { if (!ModelState.IsValid) { return(View(addModel)); } var role = new IdentityRole { Name = addModel.RoleName, }; var result = await _roleManager.CreateAsync(role); if (result.Succeeded) { return(RedirectToAction("Index")); } foreach (var item in result.Errors) { ModelState.AddModelError(string.Empty, item.Description); } return(View(addModel)); }
public IActionResult AddRole(RoleAddModel model) { if (ModelState.IsValid) { using (var uow = _identityDataService.StartUnitOfWork()) { var role = new IdentityRoleEntity { ApplicationId = 0, Name = model.Name, Description = model.Description, Identifier = Guid.NewGuid(), NormalizedName = model.Name.ToUpper() }; uow.RoleRepository.Add(role); uow.Commit(); return(RedirectToAction(nameof(ManageRoles))); } } return(View(model)); }
public Task <IResultModel> Add(RoleAddModel model) { return(_service.Add(model)); }
public Task <bool> AddSpecified(RoleAddModel model) { return(Task.FromResult(true)); }
public IActionResult Add() { var model = new RoleAddModel(); return(View(model)); }
/// <summary> /// 新增角色信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public static OperationResult AddRoleInfo(RoleAddModel model, int CreateUserID) { int count = 1 + model.FunctionIDs.Count; string[] sqls = new string[count]; #region 新增角色信息到角色表 sqls[0] = @"INSERT INTO dbo.Roles ( RoleName , [Description],CreateUserID )VALUES ( @RoleName ,@Description ,@CreateUserID);SELECT SCOPE_IDENTITY()"; SqlParameter[][] paras = new SqlParameter[count][]; paras[0] = new SqlParameter[3]; paras[0][0] = new SqlParameter() { ParameterName = "@RoleName", SqlDbType = SqlDbType.NVarChar, Size = 200, Value = model.RoleName.Trim() }; paras[0][1] = new SqlParameter("@Description", SqlDbType.NVarChar, 500); paras[0][2] = new SqlParameter("@CreateUserID", SqlDbType.Int); if (string.IsNullOrWhiteSpace(model.Description)) { paras[0][1].Value = DBNull.Value; } else { paras[0][1].Value = model.Description; } paras[0][2].Value = CreateUserID; #endregion #region 新增角色与功能关联信息 for (int i = 0; i < model.FunctionIDs.Count; i++) { int index = i + 1; sqls[index] = @"INSERT INTO dbo.RolesFunctions( RoleID, FunctionID ) VALUES ( @RoleID, @FunctionID )"; paras[index] = new SqlParameter[2]; paras[index][0] = new SqlParameter { ParameterName = "@RoleID", SqlDbType = SqlDbType.Int }; paras[index][1] = new SqlParameter() { ParameterName = "@FunctionID", SqlDbType = SqlDbType.Int, Value = model.FunctionIDs[i] }; } #endregion bool result = MSSQLHelper.ExecuteIdentityIncludeTransaction(CommandType.Text, sqls, paras) != 0; return(new OperationResult() { Success = result, Message = result ? PromptInformation.OperationSuccess : PromptInformation.DBError }); }
public Task <IResultModel> Add(RoleAddModel model) { return(Task.FromResult(ResultModel.Success("新增"))); }
public ActionResult AddRoles(RoleAddModel model) { _roleService.AddRoleAndMap(model); return(RedirectToAction("Index", "Home")); }