using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Entities.DTO;

namespace Entities.Contracts
{
	[Table("assignment_questions")]
	public class AssignmentQuestion
	{
		[Key]
		[Column("id")]
		public Guid Id { get; set; }

		[Column("question_id")]
		public Guid? QuestionId { get; set; }

		[Column("title")]
		[MaxLength(1024)]
		public string? Title { get; set; }

		[Column("description")]
		public Guid? QuestionContextId { get; set; }

		[Required]
		[Column("question_number")]
		public byte Index { get; set; }

		[Column("sequence")]
		public string Sequence { get; set; } = string.Empty;

		[Column("parent_question_group_id")]
		public Guid? ParentAssignmentQuestionId { get; set; }

		[Column("group_state")]
		public AssignmentStructType StructType { get; set; } = AssignmentStructType.Question;

		[Column("created_at")]
		public DateTime CreatedAt { get; set; }

		[Column("score")]
		public float? Score { get; set; }

		[Column("deleted")]
		public bool IsDeleted { get; set; }


		public Question? Question { get; set; }
		public Assignment? Assignment { get; set; }

		[ForeignKey(nameof(QuestionContextId))]
		public QuestionContext? QuestionContext { get; set; }

		public ICollection<SubmissionDetail> SubmissionDetails { get; set; }

		[ForeignKey(nameof(ParentAssignmentQuestionId))]
		public AssignmentQuestion? ParentAssignmentQuestion { get; set; }
		public ICollection<AssignmentQuestion> ChildrenAssignmentQuestion { get; set; } = new List<AssignmentQuestion>();


		public AssignmentQuestion()
		{
			Id = Guid.NewGuid();
			SubmissionDetails = new HashSet<SubmissionDetail>();
		}
	}
}
