public async Task <IActionResult> GetProfile() { ObjectId currentUser = ObjectId.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); // basic info var mongoDb = _mongoService.GetDb; var mongoSettings = _mongoService.GetDBSettings; var userCollection = mongoDb.GetCollection <Models.User>(mongoSettings.UserCollectionName); var filterUser = Builders <Models.User> .Filter.Eq(u => u.Id, currentUser); var user = (await userCollection.FindAsync <Models.User>(filterUser)).FirstOrDefault(); var ratingQuery = _neoContext.Cypher .OptionalMatch("(u:User {Id:'" + currentUser.ToString() + "'})-[rel:CREATED]->(t:Ticket)<-[:UPVOTED]-(u2:User)") .With("count(u2) AS ups") .OptionalMatch("(u)-[rel2:CREATED]->(t:Ticket)<-[:DOWNVOTED]-(u3:User)") .With("ups - count(u3) AS res") .Return <int>("res"); var ratingQueryText = ratingQuery.Query.DebugQueryText; var rating = await ratingQuery.ResultsAsync; var topics = await _neoContext.Cypher .Match("(u:User {Id:'" + currentUser.ToString() + "'})-[rel:INTERESTED]->(t:Topic)") .With("t.Name AS Name") .Return((Name) => new { Name = Name.As <string>() }) .ResultsAsync; var otherTopicsQuery = _neoContext.Cypher .Match("(u:User {Id:'" + currentUser.ToString() + "'})") .Match("(t:Topic)") .Where("NOT (u)-[:INTERESTED]->(t)") .With("t.Name AS Name") .Return((Name) => new { Name = Name.As <string>() }); var otherTopicsQueryText = otherTopicsQuery.Query.DebugQueryText; var otherTopics = await otherTopicsQuery .ResultsAsync; var returnDTO = new UserProfileDTO { Username = user.Username, LikedTopics = topics.Select(x => x.Name).ToList(), OtherTopics = otherTopics.Select(x => x.Name).ToList(), Rating = rating.ToList()[0] }; return(Ok(returnDTO)); }