Edit and create blog posts

This commit is contained in:
Robert Marshall 2020-01-03 10:47:13 +00:00
parent 47431d4650
commit 44875a6a45
6 changed files with 126 additions and 1 deletions

View file

@ -5,6 +5,10 @@ namespace Website.Models
{
public class BlogPost
{
public BlogPost() {
}
public BlogPost(BlogPostState state)
{
Id = state.Post_Id;
@ -23,5 +27,17 @@ namespace Website.Models
public string Draft { get; private set; }
public string Url { get; private set; }
public int UserId { get; private set; }
private void GenerateUrl() {
Url = Title.Replace(' ', '-');
}
public void UpdateTitle(string title) {
Title = title;
GenerateUrl();
}
public void UpdateDraft(string content) => Draft = content;
public void Publish() => Content = Draft;
}
}

View file

@ -0,0 +1,7 @@
namespace Website.Models {
public class BlogPostSubmission {
public int? Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
}
}