public async Task <IActionResult> AddCandidateToTest([FromForm] Guid testid, List <AddCandidateToTestViewModel> model) { var test = testRepository.FindTest(testid); if (ModelState.IsValid) { if (test == null) { return(NotFound(test)); } for (int i = 0; i < model.Count; i++) { var user = await userManager.FindByIdAsync(model[i].CandidateId); //IdentityResult result = null; if (model[i].IsSelected && !testRepository.IsCandidateInTest(model[i].CandidateId, testid)) { testRepository.AddToTest(model[i].CandidateId, testid); } else if (!model[i].IsSelected && testRepository.IsCandidateInTest(model[i].CandidateId, testid)) { testRepository.RemoveFromTest(model[i].CandidateId, testid); } else { continue; } } } return(RedirectToAction("dashboard", "administration")); }