Use new API for blog

This commit is contained in:
Robert Marshall 2020-04-11 13:37:14 +01:00
parent e389b2404a
commit 25c320bf6b
17 changed files with 356 additions and 314 deletions

View file

@ -1,44 +1,15 @@
using System;
using System.Text.RegularExpressions;
using Website.Data.States;
using System;
namespace Website.Models
{
public class BlogPost
{
public BlogPost() {
}
public BlogPost(BlogPostState state)
{
Id = state.Post_Id;
Title = state.Post_Title;
Content = state.Post_Content;
Timestamp = state.Post_Timestamp;
Draft = state.Post_Draft;
Url = state.Post_Url;
UserId = state.User_Id;
}
public int Id { get; private set; }
public string Title { get; private set; }
public string Content { get; private set; }
public DateTime Timestamp { get; private set; }
public string Draft { get; private set; }
public string Url { get; private set; }
public int UserId { get; private set; }
private void GenerateUrl() {
Url = Regex.Replace(Title, @"[^a-zA-Z0-9\.]+", "-").ToLower();
}
public void UpdateTitle(string title) {
Title = title;
GenerateUrl();
}
public void UpdateDraft(string content) => Draft = content;
public void Publish() => Content = Draft;
public int Id { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public DateTime Timestamp { get; set; }
public string Draft { get; set; }
public string Url { get; set; }
public int UserId { get; set; }
}
}
}