using DTOs;
using Entities;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExtensionsClassLibrairie
{
    /// <summary>
    /// define some methods to manipulate entity, model and dto chapters :
    /// convert model to DTO, model to Entity, ...
    /// and equality protocols
    /// </summary>
    public static class ChapterExtensionMethods
    {
        // conversion methods
        public static Chapter ToModel(this ChapterEntity c)
            => new Chapter(c.Name, c.Id);
        public static Chapter ToModel(this ChapterDto c)
            => new Chapter(c.Name, c.Id);
        public static ChapterDto ToDto(this Chapter c)
            => new ChapterDto { Id = c.Id, Name = c.Name };
        public static ChapterEntity ToEntity(this Chapter c)
            => new ChapterEntity { Id = c.Id, Name = c.Name };

        // reuse other methods
        public static ChapterDto ToDto(this ChapterEntity c)
            => c.ToModel().ToDto();
        public static ChapterEntity ToEntity(this ChapterDto c)
            => c.ToModel().ToEntity();
    }
}
