Basic post management

This commit is contained in:
Robert Marshall 2020-01-03 11:16:12 +00:00
parent 44875a6a45
commit 8f0c4c0a45
4 changed files with 65 additions and 5 deletions

View file

@ -67,5 +67,25 @@ namespace Website.Controllers
return RedirectToAction(nameof(Edit), new{savedPost.Id});
}
public async Task<IActionResult> Manage() {
var posts = await _repo.GetAllPostsAsync();
var models = posts.OrderByDescending(post => post.Timestamp).Select(post => new BlogPostViewModel(post));
return View(models);
}
public async Task<IActionResult> Publish(int id) {
var post = await _repo.GetPostByIdAsync(id);
post.Publish();
await _repo.SavePost(post);
return RedirectToAction(nameof(Manage));
}
public async Task<IActionResult> Delete(int id) {
await _repo.DeletePostAsync(id);
return RedirectToAction(nameof(Manage));
}
}
}