public IActionResult RemoveAdminUser(int tournamentId, string userId) { //This is messy ZB... clean up your room TournamentAdministratorVm viewModel = new TournamentAdministratorVm(_tournamentManagement.GetTournamentById(tournamentId)); viewModel.AdminUsers = _tournamentAdministratorManagement.GetTournamentAdministrators(tournamentId); viewModel.AvailableUsers = _tournamentAdministratorManagement.GetAvailableUsers(tournamentId, viewModel.AdminUsers); RemoveTournamentAdministratorVmValidator validator = new RemoveTournamentAdministratorVmValidator(); ValidationResult validationResult = validator.Validate(viewModel); if (validationResult.IsValid) { var user = _userManager.FindByIdAsync(userId); _tournamentManagement.RemoveTournamentAdministrator(tournamentId, user.Result); } else { foreach (ValidationFailure failure in validationResult.Errors) { ModelState.AddModelError("AdminUsers", failure.ErrorMessage); } } return(RedirectToAction("Index", new { tournamentId })); }
public IActionResult Index(int tournamentId) { TournamentAdministratorVm viewModel = new TournamentAdministratorVm(_tournamentManagement.GetTournamentById(tournamentId)); viewModel.AdminUsers = _tournamentAdministratorManagement.GetTournamentAdministrators(tournamentId); viewModel.AvailableUsers = _tournamentAdministratorManagement.GetAvailableUsers(tournamentId, viewModel.AdminUsers); return(View("Index", viewModel)); }