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); }
public async Task ReplaceRoles(User user, string roleName) { var role = await roleRepo.FindByName(roleName) ?? throw new EntityNotFoundException(); await roleRepo.AddToUser(user, role, true); }