public async Task <IActionResult> Index() { List <VolunteerDataModel> volunteers = await _volunteerService.GetAllVolunteersAsync(); VolunteerViewModel volunteerViewModel = new() { VolunteerIds = new List <string>() }; if (volunteers.Count > 0) { try { _logger.LogInformation("Trying to add volunteerIds to list..."); foreach (var u in volunteers) { volunteerViewModel.VolunteerIds.Add(u.Id); } _logger.LogInformation("Successfully created list"); return(View(volunteerViewModel)); } catch (Exception ex) { _logger.LogError(ex.Message); } } return(View(volunteerViewModel)); }