コード例 #1
0
        public async override Task Execute(AddRoleToUserCommand input, User?user)
        {
            var userToRemoveFrom = await userRepo.FindById(input.UserId) ?? throw new EntityNotFoundException();

            var role = await roleRepo.FindById(input.RoleId) ?? throw new EntityNotFoundException();

            await roleRepo.AddToUser(userToRemoveFrom, role);
        }
コード例 #2
0
        public async Task ReplaceRoles(User user, string roleName)
        {
            var role = await roleRepo.FindByName(roleName) ?? throw new EntityNotFoundException();

            await roleRepo.AddToUser(user, role, true);
        }