Last active
May 9, 2020 00:13
-
-
Save celsojr/0fd99a9eaae989c4fe3ff366349b6685 to your computer and use it in GitHub Desktop.
See the blog post here: https://celsojr.com/wp/archives/576
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// DELETE api/v1/author/{authorId} | |
/// <summary> | |
/// Deletes an Author | |
/// </summary> | |
/// <remarks>Deletes an Author</remarks> | |
/// <param name="authorId"></param> | |
[HttpDelete("{authorId:length(24)}", Name = nameof(DeleteAuthor))] | |
[ProducesResponseType(StatusCodes.Status404NotFound)] | |
[ProducesResponseType(typeof(DeleteModel<>), StatusCodes.Status200OK)] | |
public async Task<IActionResult> DeleteAuthor(string authorId) | |
{ | |
var author = await _unitOfWork.Library.GetAuthorById(authorId); | |
if (author == null) | |
{ | |
return NotFound(); | |
} | |
var undoObject = new DeleteModel<string> { ResourceId = authorId }; | |
_memoryCache.Set(authorId, author, undoObject.ExpireTime); | |
_unitOfWork.Library.RemoveAuthor(authorId); | |
await _unitOfWork.Commit(); | |
return Ok(undoObject); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment