| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- namespace Domain.Entities.News
- {
- public class RssNewsArticle
- {
- [ForeignKey(nameof(RssFeedSourceID))]
- public virtual RssFeedSource RssFeedSource { get; set; } = null!;
- [Key]
- public int ID { get; private set; }
- public int RssFeedSourceID { get; private set; }
- public string Title { get; private set; } = default!;
- public string? Link { get; private set; }
- public string? Guid { get; private set; }
- public string? Author { get; private set; }
- public string? Description { get; private set; }
- public string? Content { get; private set; }
- public string? ImageUrl { get; private set; }
- public string? SourceName { get; private set; }
- public string? Categories { get; private set; }
- public int CommentCount { get; private set; } = 0;
- public DateTime? PublishedAt { get; private set; }
- public DateTime CreatedAt { get; private set; } = DateTime.UtcNow;
- private RssNewsArticle() { }
- private RssNewsArticle(
- int rssFeedSourceID,
- string title,
- string? link,
- string? guid,
- string? author,
- string? description,
- string? content,
- string? imageUrl,
- string? sourceName,
- string? categories,
- int commentCount,
- DateTime? publishedAt
- ) {
- if (string.IsNullOrWhiteSpace(title))
- {
- throw new ArgumentException("Title is required.", nameof(title));
- }
- if (title.Length > 500)
- {
- title = title[..500];
- }
- RssFeedSourceID = rssFeedSourceID;
- Title = title;
- Link = link;
- Guid = guid;
- Author = author;
- Description = description;
- Content = content;
- ImageUrl = imageUrl;
- SourceName = sourceName;
- Categories = categories;
- CommentCount = commentCount;
- PublishedAt = publishedAt;
- }
- public static RssNewsArticle Create(
- int rssFeedSourceID,
- string title,
- string? link = null,
- string? guid = null,
- string? author = null,
- string? description = null,
- string? content = null,
- string? imageUrl = null,
- string? sourceName = null,
- string? categories = null,
- int commentCount = 0,
- DateTime? publishedAt = null
- ) => new(rssFeedSourceID, title, link, guid, author, description, content, imageUrl, sourceName, categories, commentCount, publishedAt);
- }
- }
|