using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Bson;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Postall.Domain.Dtos;

namespace Postall.Domain.Entities
{
    /// <summary>
    /// Modelo de dados para armazenamento do canal no MongoDB
    /// </summary>
    public class ChannelData
    {
        [BsonId]
        [BsonRepresentation(BsonType.String)]
        public string Id { get; set; }

        [BsonElement("userId")]
        public string UserId { get; set; }

        [BsonElement("channelId")]
        public string ChannelId { get; set; }

        [BsonElement("youtubeId")]
        public string YoutubeId { get; set; }

        [BsonElement("title")]
        public string Title { get; set; }

        [BsonElement("description")]
        public string Description { get; set; }

        [BsonElement("thumbnailUrl")]
        public string ThumbnailUrl { get; set; }

        [BsonElement("publishedAt")]
        public DateTime PublishedAt { get; set; }

        [BsonElement("subscriberCount")]
        public ulong SubscriberCount { get; set; }

        [BsonElement("videoCount")]
        public ulong VideoCount { get; set; }

        [BsonElement("isSelected")]
        public bool IsSelected { get; set; }

        [BsonIgnore]
        public string ChannelUrl => $"https://www.youtube.com/channel/{YoutubeId}";

        public ChannelResponse ToChannelResponse() => new ChannelResponse
        {
            Id = Id,
            UserId = UserId,
            YoutubeId = YoutubeId,
            Title = Title,
            Description = Description,
            ThumbnailUrl = ThumbnailUrl,
            PublishedAt = PublishedAt,
            SubscriberCount = SubscriberCount,
            VideoCount = VideoCount
        };
    }
}
