Get the latest commit and show it on the home page
This commit is contained in:
parent
ffb3e791ab
commit
5d67e92245
23 changed files with 233 additions and 60 deletions
|
@ -2,22 +2,29 @@
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Website.Data;
|
||||
using Website.ViewModels;
|
||||
using System.Linq;
|
||||
|
||||
namespace Website.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
namespace Website.Controllers {
|
||||
public class HomeController : Controller {
|
||||
private readonly BlogRepository _blogRepo;
|
||||
private readonly GitServerApi _api;
|
||||
|
||||
public HomeController(BlogRepository blogRepo)
|
||||
{
|
||||
public HomeController(BlogRepository blogRepo, GitServerApi api) {
|
||||
_api = api;
|
||||
_blogRepo = blogRepo;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index()
|
||||
{
|
||||
public async Task<IActionResult> Index() {
|
||||
var post = await _blogRepo.GetLatestPostAsync();
|
||||
var model = new BlogPostViewModel(post, false);
|
||||
var repo = (await _api.GetRepositories()).First();
|
||||
var branch = (await _api.GetBranches(repo.Name)).First();
|
||||
var commit = await _api.GetCommit(repo.Name, branch.Commit.Id);
|
||||
|
||||
var model = new HomeViewModel {
|
||||
BlogPost = new BlogPostViewModel(post, false),
|
||||
GitCommit = new GitCommitViewModel(repo, branch, commit)
|
||||
};
|
||||
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue