async public Task <IActionResult> OnPostAsync()
        {
            string roleId = String.Empty;

            return(await SecureHandlerAsync(async() =>
            {
                if (!ModelState.IsValid)
                {
                    throw new StatusMessageException($"Type a valid role name.");
                }

                var role = new ApplicationRole()
                {
                    Id = CreateInput.Rolename, Name = CreateInput.Rolename, Description = CreateInput.Description
                };
                await _roleDb.CreateAsync(role, CancellationToken.None);

                roleId = role.Id;
            },
                                            onFinally : () => RedirectToPage("EditRole/Index", new { id = roleId }),
                                            successMessage : "",
                                            onException : (ex) => RedirectToPage()));
        }
Exemple #2
0
 public Task <IdentityResult> CreateAsync(ApplicationRole role, CancellationToken cancellationToken)
 {
     return(_roleDbContext.CreateAsync(role, cancellationToken));
 }