using Microsoft.IdentityModel.Tokens;

namespace Netina.Domain.Entities.Blogs;

public partial class Blog
{
    public static Blog Create(string title, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
    {
        var slug = StringExtensions.GetSlug(title);
        return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
    }

    public static Blog Create(string title, string slug, string content, string tags, int readingTime, string summery, bool isSuggested, Guid categoryId)
    {
        if (slug.IsNullOrEmpty())
            slug = StringExtensions.GetSlug(title);
        return new Blog(title, slug, content, tags, readingTime, summery, isSuggested, categoryId);
    }
    public BlogStorageFile AddFile(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType)
    {
        var file = BlogStorageFile.Create(name, fileLocation, fileName, isHeader, isPrimary, fileType, this.Id);
        Files.Add(file);
        return file;
    }
}

public partial class BlogStorageFile
{
    public static BlogStorageFile Create(string name, string fileLocation, string fileName, bool isHeader, bool isPrimary, StorageFileType fileType, Guid blogId)
    {
        return new BlogStorageFile(name, fileLocation, fileName, isHeader, isPrimary, fileType, blogId);
    }
}

public partial class BlogCategory
{
    public static BlogCategory Create(string name, string description, bool isMain)
    {
        var slug = StringExtensions.GetSlug(name);
        return new BlogCategory(name, slug, description, isMain);
    }
    public static BlogCategory Create(string name, string slug, string description,bool isMain)
    {
        if (slug.IsNullOrEmpty())
            slug = StringExtensions.GetSlug(name);
        return new BlogCategory(name, slug, description, isMain);
    }

    public void SetParent(Guid parentId)
    {
        ParentId = parentId;
    }
}