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