public IActionResult Profile([FromQuery] string Info, [FromQuery] bool Success) { string uniqueId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value; AppUser user = UserService.GetUserByUniqueId(uniqueId).Result; if (user == null) { ViewBag.UserNotFound = true; string email = User.Claims.FirstOrDefault(c => c.Type == "name")?.Value; string profileImg = User.Claims.FirstOrDefault(c => c.Type == "picture")?.Value; string nickname = User.Claims.FirstOrDefault(c => c.Type == "nickname")?.Value; string name = ""; string current_email = User.Claims.FirstOrDefault(c => c.Type == @"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress")?.Value; if (!email.Contains('@') && !email.Contains('.')) { if (current_email != null) { name = email; email = current_email; } else { name = email; email = nickname + "@gmail.com"; } } var myDogs = DogService.GetDogsByUser(uniqueId).Result; return(View(new UserProfileViewModel { UniqueId = uniqueId, Email = email, ProfileImage = profileImg, Nickname = nickname, Name = name, MyDogs = myDogs, SavedDogs = null })); } else { ViewBag.UserNotFound = false; if (Info != null) { ViewBag.Info = Info; ViewBag.Success = Success; } List <Dog> thisUserDogs = new List <Dog>(); if (user.Dogs != null) { thisUserDogs = user.Dogs; } return(View(new UserProfileViewModel { UniqueId = user.UniqueId, Email = user.Email, ProfileImage = user.ProfileImage, Nickname = user.Nickname, Name = user.Name, MyDogs = thisUserDogs, SavedDogs = new List <Dog>() })); } }