File tree Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Expand file tree Collapse file tree 4 files changed +42
-1
lines changed Original file line number Diff line number Diff line change 52
52
{
53
53
< p > Found @SearchResult .TotalReplays replays in @stopWatch .ElapsedMilliseconds ms < / p >
54
54
}
55
+
56
+ if (ProfileFound != null )
57
+ {
58
+ < p > Profile found for @ProfileFound .Username , click < a href = " /player/@ProfileFound.PlayerGuid" > here < / a > to view < / p >
59
+ }
55
60
56
61
< p > Page @pageDisplay of @SearchResult .PageCount < / p >
57
62
< div class = " replay-list" >
99
104
public string ? ErrorMessage { get ; set ; }
100
105
public string ? ErrorDetails { get ; set ; }
101
106
public Stopwatch stopWatch { get ; set ; } = new Stopwatch ();
107
+ public PlayerData ? ProfileFound { get ; set ; }
102
108
103
109
public SearchResult SearchResult { get ; set ; } = new SearchResult ();
104
110
136
142
stopWatch .Stop ();
137
143
return ;
138
144
}
145
+
146
+ if (loadedReplays .SearchMode is SearchMode .PlayerOocName )
147
+ {
148
+ var playerGuid = await Http .GetAsync (" /api/Data/has-profile?username=" + loadedReplays .Query );
149
+ ProfileFound = await playerGuid .Content .ReadFromJsonAsync <PlayerData >();
150
+ }
139
151
140
152
SearchResult = loadedReplays ;
141
153
stopWatch .Stop ();
Original file line number Diff line number Diff line change @@ -192,6 +192,31 @@ [FromQuery] string username
192
192
return Ok ( completions ) ;
193
193
}
194
194
195
+ /// <summary>
196
+ /// Tries to find a player with the given username. If found, returns the player's GUID.
197
+ /// </summary>
198
+ [ HttpGet ]
199
+ [ Route ( "has-profile" ) ]
200
+ public async Task < PlayerData > HasProfile (
201
+ [ FromQuery ] string username
202
+ )
203
+ {
204
+ var player = await _context . Players
205
+ . FirstOrDefaultAsync ( p => p . PlayerOocName . ToLower ( ) == username . ToLower ( ) ) ;
206
+ if ( player == null )
207
+ return new PlayerData ( )
208
+ {
209
+ PlayerGuid = Guid . Empty ,
210
+ Username = "NOT FOUND"
211
+ } ;
212
+
213
+ return new PlayerData ( )
214
+ {
215
+ PlayerGuid = player . PlayerGuid ,
216
+ Username = player . PlayerOocName
217
+ } ;
218
+ }
219
+
195
220
[ HttpGet ]
196
221
[ Route ( "leaderboard" ) ]
197
222
public async Task < LeaderboardData > GetLeaderboard (
Original file line number Diff line number Diff line change @@ -109,7 +109,9 @@ public async Task<ActionResult> SearchReplays(
109
109
PageCount = pageCount ,
110
110
CurrentPage = page ,
111
111
TotalReplays = found . Item2 ,
112
- IsCache = found . Item3
112
+ IsCache = found . Item3 ,
113
+ SearchMode = searchMode ,
114
+ Query = query
113
115
} ) ;
114
116
}
115
117
Original file line number Diff line number Diff line change @@ -12,4 +12,6 @@ public class SearchResult
12
12
public int CurrentPage { get ; set ; } = 1 ;
13
13
public List < Replay > Replays { get ; set ; } = new ( ) ;
14
14
public int TotalReplays { get ; set ; } = 0 ;
15
+ public SearchMode SearchMode { get ; set ; }
16
+ public string Query { get ; set ; } = "" ;
15
17
}
You can’t perform that action at this time.
0 commit comments