Return blog post count
This commit is contained in:
parent
67c71d4d06
commit
71bddddc13
2 changed files with 34 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue