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 answers :
    /// convert model to DTO, model to Entity, ...
    /// and equality protocols
    /// </summary>
    public static class AnswerExtensionMethods
    {
        // conversion methods
        public static Answer ToModel(this AnswerEntity a)
            => new Answer(a.Content, a.IdQuestion , a.Id);
        public static Answer ToModel(this AnswerDto a)
            => new Answer(a.Content, a.IdQuestion, a.Id);
        public static AnswerDto ToDto(this Answer a)
            => new AnswerDto { Id = a.Id, Content = a.Content, IdQuestion = a.IdQuestion };
        public static AnswerEntity ToEntity(this Answer a)
            => new AnswerEntity { Id = a.Id, Content = a.Content, IdQuestion = a.IdQuestion };

        // reuse other methods
        public static AnswerDto ToDto(this AnswerEntity a)
            => a.ToModel().ToDto();
        public static AnswerEntity ToEntity(this AnswerDto a)
            => a.ToModel().ToEntity();
    }
}
