forked from gothinkster/aspnetcore-realworld-example-app
/
Article.cs
47 lines (32 loc) · 1.14 KB
/
Article.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
namespace Conduit.Domain
{
public class Article
{
[JsonIgnore]
public int ArticleId { get; set; }
public string Slug { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public string Body { get; set; }
public Person Author { get; set; }
public List<Comment> Comments {get;set; }
[NotMapped]
public bool Favorited => ArticleFavorites?.Any() ?? false;
[NotMapped]
public int FavoritesCount => ArticleFavorites?.Count ?? 0;
[NotMapped]
public List<string> TagList => (ArticleTags?.Select(x => x.TagId) ?? Enumerable.Empty<string>()).ToList();
[JsonIgnore]
public List<ArticleTag> ArticleTags { get; set; }
[JsonIgnore]
public List<ArticleFavorite> ArticleFavorites { get; set; }
public DateTime CreatedAt { get; set; }
public DateTime UpdatedAt { get; set; }
public bool IsSpam { get; set; }
}
}