website/Website/Controllers/BlogController.cs

33 lines
658 B
C#

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Website.Data;
using Website.ViewModels;
namespace Website.Controllers
{
public class BlogController : Controller
{
private readonly BlogRepository _repo;
public BlogController(BlogRepository repo)
{
_repo = repo;
}
public IActionResult Index()
{
return View();
}
public async Task<IActionResult> View(int id)
{
var post = await _repo.GetPostAsync(id);
var model = new BlogPostViewModel(post);
return View(model);
}
}
}