@@ -16,6 +16,8 @@ public class PlayerController(
1616 IValidator < PlayerRequestModel > validator
1717) : ControllerBase
1818{
19+ private const string NotFoundTitle = "Not Found" ;
20+
1921 /* -------------------------------------------------------------------------
2022 * HTTP POST
2123 * ---------------------------------------------------------------------- */
@@ -104,7 +106,7 @@ public async Task<IResult> GetAsync()
104106 logger . LogWarning ( "GET /players not found" ) ;
105107 return TypedResults . Problem (
106108 statusCode : StatusCodes . Status404NotFound ,
107- title : "Not Found" ,
109+ title : NotFoundTitle ,
108110 detail : "No players were found." ,
109111 instance : HttpContext ? . Request ? . Path . ToString ( )
110112 ) ;
@@ -134,7 +136,7 @@ public async Task<IResult> GetByIdAsync([FromRoute] Guid id)
134136 logger . LogWarning ( "GET /players/{Id} not found" , id ) ;
135137 return TypedResults . Problem (
136138 statusCode : StatusCodes . Status404NotFound ,
137- title : "Not Found" ,
139+ title : NotFoundTitle ,
138140 detail : $ "Player with Id '{ id } ' was not found.",
139141 instance : HttpContext ? . Request ? . Path . ToString ( )
140142 ) ;
@@ -167,7 +169,7 @@ public async Task<IResult> GetBySquadNumberAsync([FromRoute] int squadNumber)
167169 logger . LogWarning ( "GET /players/squadNumber/{SquadNumber} not found" , squadNumber ) ;
168170 return TypedResults . Problem (
169171 statusCode : StatusCodes . Status404NotFound ,
170- title : "Not Found" ,
172+ title : NotFoundTitle ,
171173 detail : $ "Player with Squad Number '{ squadNumber } ' was not found.",
172174 instance : HttpContext ? . Request ? . Path . ToString ( )
173175 ) ;
@@ -234,15 +236,15 @@ [FromBody] PlayerRequestModel player
234236 logger . LogWarning ( "PUT /players/squadNumber/{SquadNumber} not found" , squadNumber ) ;
235237 return TypedResults . Problem (
236238 statusCode : StatusCodes . Status404NotFound ,
237- title : "Not Found" ,
239+ title : NotFoundTitle ,
238240 detail : $ "Player with Squad Number '{ squadNumber } ' was not found.",
239241 instance : HttpContext ? . Request ? . Path . ToString ( )
240242 ) ;
241243 }
242244 await playerService . UpdateAsync ( player ) ;
243245 // Sanitize user-provided player data before logging to prevent log forging
244246 var sanitizedPlayerString = player
245- ? . ToString ( )
247+ . ToString ( )
246248 ? . Replace ( Environment . NewLine , string . Empty )
247249 . Replace ( "\r " , string . Empty )
248250 . Replace ( "\n " , string . Empty ) ;
0 commit comments