Get latest blog post

This commit is contained in:
Robert Marshall 2020-04-10 10:35:08 +01:00
parent c1eff209eb
commit 67c71d4d06
2 changed files with 33 additions and 4 deletions

View file

@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@ -53,8 +52,14 @@ namespace Robware.Api.Blog.Controllers {
}
[HttpGet(nameof(GetLatestPost))]
public async Task<BlogPost> GetLatestPost() {
return null;
public async Task<ActionResult<BlogPost>> GetLatestPost() {
try {
return await _blogRepository.GetLatestPostAsync();
}
catch (ItemNotFoundException e) {
_logger.Log(LogLevel.Error, e.Message);
return NotFound("Could not find blog post");
}
}
//[HttpGet]