Esempio n. 1
0
    public async Task DeleteAsync()
    {
        var role = await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"));

        role.ShouldNotBeNull();

        await _identityRoleManager.DeleteAsync(role);

        (await _identityRoleRepository.FindByNormalizedNameAsync(_lookupNormalizer.NormalizeName("moderator"))).ShouldBeNull();
    }
Esempio n. 2
0
        public override async Task <IActionResult> Delete(int id)
        {
            Role role = await roleManager.FindByIdAsync(id.ToString());

            if (role != null)
            {
                IdentityResult result = await roleManager.DeleteAsync(role);

                if (result.Succeeded)
                {
                    return(NoContent());
                }
            }
            ModelState.AddModelError("Errors", "Role doesn't exists.");
            return(NotFound());
        }