Return blog post count

This commit is contained in:
Robert Marshall 2020-04-10 12:34:20 +01:00
parent 67c71d4d06
commit 71bddddc13
2 changed files with 34 additions and 3 deletions

View file

@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@ -62,8 +63,16 @@ namespace Robware.Api.Blog.Controllers {
}
}
//[HttpGet]
//Task<int> GetCount();
[HttpGet(nameof(GetCount))]
public async Task<ActionResult<int>> GetCount() {
try {
return await _blogRepository.GetCountAsync();
}
catch (ItemNotFoundException e) {
_logger.Log(LogLevel.Error, e.Message);
return 0;
}
}
//[HttpPost]
//Task<BlogPost> SavePost(BlogPost post);