31 lines
894 B
C#
31 lines
894 B
C#
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Website.Data;
|
|
using Website.ViewModels;
|
|
using System.Linq;
|
|
|
|
namespace Website.Controllers {
|
|
public class HomeController : Controller {
|
|
private readonly IBlogApi _blogApi;
|
|
private readonly IGitApi _api;
|
|
|
|
public HomeController(IBlogApi blogApi, IGitApi api) {
|
|
_api = api;
|
|
_blogApi = blogApi;
|
|
}
|
|
|
|
public async Task<IActionResult> Index() {
|
|
var post = await _blogApi.GetLatestPostAsync();
|
|
var repo = (await _api.GetRepositories("rob")).First();
|
|
var branch = (await _api.GetBranches("rob", repo.Name)).First();
|
|
var commit = await _api.GetCommit("rob", repo.Name, branch.Commit.Id);
|
|
|
|
var model = new HomeViewModel {
|
|
BlogPost = new BlogPostViewModel(post, false),
|
|
GitCommit = new GitCommitViewModel(repo, branch, commit)
|
|
};
|
|
|
|
return View(model);
|
|
}
|
|
}
|
|
}
|