using Microsoft.IdentityModel.Tokens;

namespace NetinaShop.Domain.Dtos.SmallDtos;

public class StorageFileSDto : BaseDto<StorageFileSDto , StorageFile>
{
    public string Name { get; set; } = string.Empty;
    public string FileLocation { get; set; } = string.Empty;
    public string FileName { get; set; } = string.Empty;
    public bool IsHeader { get; set; }
    public bool IsPrimary { get; set; }
    public StorageFileType FileType { get; set; }
    public bool Selected { get; set; }

    public DateTime CreatedAt
    {
        get
        {
            string date = FileName.Split('.').First().Split('_').Last();
            if (!date.IsNullOrEmpty() && long.TryParse(date, out long longDate))
                return DateTimeExtensions.UnixTimeStampToDateTime(longDate);
            return DateTime.MinValue;
        }
    }

}