WebApplication1/Controllers/TodoController.cs
/// <summary>
/// Gets an individual TodoItem from its ID and API Key
/// </summary>
/// <param name="id">The UUID / GUID of the TodoItem</param>
/// <param name="apiKey">The API key that hosts this TodoItem</param>
/// <returns>An individual TodoItem containing the task and id</returns>
/// <response code="200">The TodoItem was found and returned</response>
/// <response code="400">The request was invalid</response>
Gets an individual TodoItem from its ID and API Key
Gets an individual TodoItem from its ID and API Key
[HttpGet("{id}")]
        [ProducesResponseType(typeof(TodoItem), (int)HttpStatusCode.OK)]
        [ProducesResponseType(typeof(void), (int)HttpStatusCode.BadRequest)]
        public IActionResult Get(Guid id, [FromQuery] string apiKey)
        {
            if (string.IsNullOrWhiteSpace(apiKey)) return BadRequest();
            if (apiKey.Length > 128) return BadRequest();
            var item = GetTodoItem(apiKey).FirstOrDefault(x => x.Id == id);
            if (item == null) return NotFound();
            return Ok(item);
        }
[ HttpGet ( " " ) ] [ ProducesResponseType ( typeof ( TodoItem ) , ( int ) HttpStatusCode . OK ) ] [ ProducesResponseType ( typeof ( void ) , ( int ) HttpStatusCode . BadRequest ) ] public IActionResult Get ( Guid id , [ FromQuery ] string apiKey ) { if ( string . IsNullOrWhiteSpace ( apiKey ) ) return BadRequest ( ) ; if ( apiKey . Length > 128 ) return BadRequest ( ) ; var item = GetTodoItem ( apiKey ) . FirstOrDefault ( x => x . Id == id ) ; if ( item == null ) return NotFound ( ) ; return Ok ( item ) ; }
Gets an individual TodoItem from its ID and API Key
Gets an individual TodoItem from its ID and API Key
// Validation // - Null Checks // - Length Checks
An individual TodoItem containing the task and id
An individual TodoItem containing the task and id
id
Guid
The UUID / GUID of the TodoItem
The UUID / GUID of the TodoItem
string
[FromQuery]
apiKey
The API key that hosts this TodoItem
The API key that hosts this TodoItem
response
The TodoItem was found and returned
The TodoItem was found and returned
response
The request was invalid
The request was invalid