using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Model
{
    /// <summary>
    /// define an answer for a Question with Mutiple Choice
    /// attributes :
    ///     id : identifier in the database
    ///     content : content of the answer
    ///     idQuestion : the id of the question which it answer to
    /// </summary>
    public class Answer
    {
        private int id;
        private string? content;
        private int? idQuestion;

        //      getters and setters for attributes
        public int Id
        {
            get => id;
            private set { id = value; }
        }
        public string Content
        {
            get => content == null ? "" : content;
            set { content = value == "" ? null : value; }
        }
        public int? IdQuestion
        {
            get => idQuestion; // null = no idQuestion
            set { idQuestion = value; }
        }

        /// <summary>
        /// constructor of an answer
        /// </summary>
        /// <param name="content">the content of the answer</param>
        /// <param name="idQuestion">the id of the question which it answer to</param>
        /// <param name="id">the id in the database</param>
        public Answer(string content, int? idQuestion = null, int id = 0)
        {
            Content = content;
            IdQuestion = idQuestion;
            Id = id;
        }

    }
}
