Newsbot.Collector/Newsbot.Collector.Domain/Dto/ArticleDto.cs

56 lines
1.7 KiB
C#

using Newsbot.Collector.Domain.Entities;
using Newsbot.Collector.Domain.Models;
namespace Newsbot.Collector.Domain.Dto;
public class ArticleDto
{
public Guid ID { get; set; }
public Guid SourceID { get; set; }
public Guid AuthorId { get; set; }
public string[]? Tags { get; set; }
public string? Title { get; set; }
public string? Url { get; set; }
public DateTime PubDate { get; set; }
public string? Video { get; set; }
public int VideoHeight { get; set; }
public int VideoWidth { get; set; }
public string? Thumbnail { get; set; }
public string? Description { get; set; }
public static ArticleDto Convert(ArticlesModel article)
{
return new ArticleDto
{
ID = article.ID,
SourceID = article.SourceID,
Tags = article.Tags.Split(','),
Title = article.Title,
Url = article.URL,
PubDate = article.PubDate,
Video = article.Video,
VideoHeight = article.VideoHeight,
VideoWidth = article.VideoWidth,
Thumbnail = article.Thumbnail,
Description = article.Description,
};
}
public static ArticleDto Convert(ArticlesEntity article)
{
return new ArticleDto
{
ID = article.Id,
SourceID = article.SourceId,
AuthorId = article.AuthorId,
Tags = article.Tags.Split(','),
Title = article.Title,
Url = article.Url,
PubDate = article.PubDate,
Video = article.Video,
VideoHeight = article.VideoHeight,
VideoWidth = article.VideoWidth,
Thumbnail = article.Thumbnail,
Description = article.Description
};
}
}