Created
July 18, 2019 09:02
-
-
Save ntakouris/8b5c439730de4afad88943a2f25720a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[HttpPost(ApiRoutes.Posts.Create)] | |
public Task<IActionResult> Create([FromBody] Post post) | |
{ | |
if (string.IsNullOrEmpty(post.Id) | |
post.Id = Guid.NewGuid().ToString(); | |
_posts.AddPost(post); | |
var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; | |
var locationUri = baseUrl + "/" + ApiRoutes.Posts.Get.Replace("{postId}", post.Id.ToString()); | |
return Created(locationUri, post); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment