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 Microsoft.EntityFrameworkCore;

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

		[Required]
		[Column("assignment_id")]
		[ForeignKey("Assignment")]
		public Guid AssignmentId { get; set; }

		[Required]
		[Column("student_id")]
		[ForeignKey("Student")]
		public Guid StudentId { get; set; }

		[Required]
		[Column("attempt_number")]
		public byte AttemptNumber { get; set; }

		[Column("submission_time")]
		public DateTime SubmissionTime { get; set; }

		[Column("overall_grade")]
		public float? OverallGrade { get; set; }

		[Column("overall_feedback")]
		public string? OverallFeedback { get; set; }

		[Column("graded_by")]
		[ForeignKey("Grader")]
		public Guid? GraderId { get; set; }

		[Column("graded_at")]
		public DateTime? GradedAt { get; set; }

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

		public byte TotalQuesNum { get; set; }

		public byte ErrorQuesNum { get; set; }

		public byte TotalScore { get; set; }

		[Required]
		[Column("status")]
		public SubmissionStatus Status { get; set; }

		// Navigation Properties
		public Assignment Assignment { get; set; }
		public User Student { get; set; }
		public User Grader { get; set; }
		public ICollection<SubmissionDetail> SubmissionDetails { get; set; }

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

}
