Пример #1
0
        public async Task <IHttpActionResult> DeleteUserRole(UserRoleModel userRole)
        {
            if (await UserRoleService.UserRoleExistsForUpdateAndDelete(userRole.ID))
            {
                var userRoleToDelete = new UserRoleModel
                {
                    ID   = userRole.ID,
                    Name = userRole.Name
                };

                CommonResponse roleResponse = await UserRoleService.DeleteRole(userRoleToDelete);

                if (roleResponse.IsError)
                {
                    return(BadRequest("Error In Deleting The User Role!"));
                }
                else
                {
                    return(Ok("User Role Deleted Successfully!"));
                }
            }
            else
            {
                return(BadRequest("User Role Does Not Exist!"));
            }
        }
Пример #2
0
        public async Task DeleteRole(CommandContext ctx, DiscordRole role)
        {
            var appDiscordRole = DiscordRoleMapper.Map(role);

            await _userRoleService.DeleteRole(appDiscordRole);

            await ctx.RespondAsync($"Deleted user role for {role.Name}");
        }
Пример #3
0
        public void DeleteRole_UserRoleNotExists_ThrowException()
        {
            var discordRole = new AppDiscordRole();

            _userRoleRepoMock
            .Setup(x => x.GetRoleByDiscordRoleId(It.IsAny <ulong>()))
            .ReturnsAsync((UserRole)null !);

            _sut = BuildSutWithMocks();

            Func <Task> act = async() => await _sut.DeleteRole(discordRole);

            act.Should()
            .ThrowAsync <ArgumentException>()
            .WithMessage("User role doesn't exist");
        }