public async Task <IActionResult> RemoveFriend(int receiverId) { // Get the sender and receiver's accountIds to create friendlist connection int senderId = _context.Account.FirstOrDefault(a => a.AspuserId == User.Identity.Name).AccountId; var friendList = _context.FriendList.FirstOrDefault(a => a.AccountId == senderId && a.FriendId == receiverId); var profile = _context.Profile.Include(a => a.Account).FirstOrDefault(p => p.AccountId == receiverId); _context.Remove(friendList); await _context.SaveChangesAsync(); return(RedirectToAction("Details", new { id = profile.ProfileId })); }