public async Task <IActionResult> GetBlog(string id) { //Try to read the blog id if (Guid.TryParse(id, out Guid blogId)) { //Try to get the blog from teh db var blog = await HealthBlogService.GetBlog(blogId, !HttpContext.User.Identity.IsAuthenticated); if (blog != null) { return(Ok(blog)); } } return(NotFound($"Blog not found with the id of {id}")); }
public async Task <IActionResult> Blog(string id) { //Try to read the blog id if (Guid.TryParse(id, out Guid blogId)) { //Try to get the blog from teh db var blog = await HealthBlogService.GetBlog(blogId, (!User.IsInRole(UserRoles.ADMIN))); if (blog != null) { return(View(new HealthBlogViewModel() { Blog = blog })); } } return(View(StaticViewNames.NOTFOUND)); }