using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace Model { /// /// 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 /// question : the question which it answer to /// public class Answer { private uint id; private string? content; private uint idQuestion; public Question? question; // getters and setters for attributes public uint Id { get => id; private set { id = value; } } public string Content { get => content == null ? "" : content; set { content = value == "" ? null : value; } } public uint IdQuestion { get => idQuestion; // null = no idQuestion private set { idQuestion = value; } } public Question? Question { get => question; private set { question = value; IdQuestion = value == null ? 0 : value.Id; } } /// /// constructor of an answer /// /// the content of the answer /// the id in the database /// the question which it answer to public Answer(string content, Question? question = null, uint id = 0) { Content = content; Id = id; Question = question; } } }