public async Task <IActionResult> Index() { string[] roles = new string[] { "Host", "Guest" }; foreach (var role in roles) { if (await _roleManager.FindByNameAsync(role) == null) { await _roleManager.CreateAsync(new IdentityRole(role)); } } //await _userManager.AddToRoleAsync(await _userManager.GetUserAsync(User), "Guest"); string UserId = _userManager.GetUserId(User); HostEventsViewModel hostEventsViewModel = new HostEventsViewModel() { EventsHosting = _hostEventsRepository.GetAllEventsHosting(UserId).ToList(), EventsAttending = _hostEventsRepository.GetAllEventsAttending(UserId).ToList(), EventInvitations = _hostEventsRepository.GetEventInvitations(_userManager.GetUserName(User)).ToList() }; return(View(hostEventsViewModel)); }