summaryrefslogtreecommitdiff
path: root/CoreWiki/Models/Article.cs
diff options
context:
space:
mode:
authorPaweł Bernaciak <pawelbernaciak@zohomail.eu>2023-12-29 09:41:56 +0100
committerPaweł Bernaciak <pawelbernaciak@zohomail.eu>2023-12-29 09:41:56 +0100
commit79f5eaf40b93d64be74d8b4f1ef80d19fadbfbe1 (patch)
treeddf121e78bdd50673379b223abfdb448c4f81291 /CoreWiki/Models/Article.cs
parent1a96616699ab41bf6343bc1acc45a836c3e6caf3 (diff)
Cywilizowany tailwindHEADmaster
Diffstat (limited to 'CoreWiki/Models/Article.cs')
-rw-r--r--CoreWiki/Models/Article.cs32
1 files changed, 24 insertions, 8 deletions
diff --git a/CoreWiki/Models/Article.cs b/CoreWiki/Models/Article.cs
index b989573..31485e3 100644
--- a/CoreWiki/Models/Article.cs
+++ b/CoreWiki/Models/Article.cs
@@ -8,15 +8,13 @@ namespace CoreWiki.Models;
public class Article
{
- [Key]
- public string Slug { get; set; }
-
+ public int Id { get; set; }
+ [Required]
+ public required string Slug { get; set; }
[Required, MaxLength(100)]
- public string Topic { get; set; }
-
+ public string? Topic { get; set; }
[NotMapped]
public Instant Published { get; set; } = SystemClock.Instance.GetCurrentInstant();
-
[Obsolete("This property is only for serialization")]
[DataType(DataType.DateTime)]
[Column("Published")]
@@ -26,8 +24,26 @@ public class Article
get => Published.ToDateTimeUtc();
set => Published = DateTime.SpecifyKind(value, DateTimeKind.Utc).ToInstant();
}
-
+ [Required]
+ public required int ViewCount { get; set; }
[DataType(DataType.MultilineText)]
[Required]
- public string Content { get; set; } = default!;
+ public string? Content { get; set; }
+
+ [NotMapped]
+ public int? EstimatedReadingTime
+ {
+ get
+ {
+ if (Content == null)
+ {
+ return null;
+ }
+ var wpm = 275.00m;
+ var wordCount = Content.Split(" ").Length;
+ return (int)Math.Ceiling(wordCount / wpm);
+ }
+ }
+
+ public ICollection<Comment> Comments { get; } = new List<Comment>();
} \ No newline at end of file