using Microsoft.AspNetCore.Identity;
using System.ComponentModel.DataAnnotations.Schema;

namespace Entities.Contracts
{

	public class User : IdentityUser<Guid>
	{
		public string? RefreshToken { get; set; }

		public DateTime? RefreshTokenExpiryTime { get; set; }
		
		public string? HomeAddress { get; set; }

		public string? DisplayName { get; set; }

		public UserRoles? Role { get; set; } 

		public Guid? TeachSubjectId { get; set; }
		[ForeignKey(nameof(TeachSubjectId))]
		public virtual Subject? TeachSubject { get; set; }

		[Column("deleted")]
		public bool IsDeleted { get; set; }
		
		[InverseProperty(nameof(ClassUser.User))]
		public virtual ICollection<ClassUser> UserInjoinedClass { get; set; }

		//[InverseProperty(nameof(Question.Creator))]
		//public virtual ICollection<Question> CreatedQuestions { get; set; }

		[InverseProperty(nameof(Exam.Creator))]
		public virtual ICollection<Exam> CreatedExams { get; set; }

		[InverseProperty(nameof(SubmissionDetail.Student))]
		public virtual ICollection<SubmissionDetail> SubmissionDetails { get; set; }

		[InverseProperty(nameof(Submission.Student))]
		public virtual ICollection<Submission> StudentSubmissions { get; set; }

		[InverseProperty(nameof(Submission.Grader))]
		public virtual ICollection<Submission> GradedSubmissions { get; set; }



		public User()
		{
			Id = Guid.NewGuid();
			SecurityStamp = Guid.NewGuid().ToString();

			//CreatedQuestions = new HashSet<Question>();
			UserInjoinedClass = new HashSet<ClassUser>();
			CreatedExams = new HashSet<Exam>();
			GradedSubmissions = new HashSet<Submission>();
			StudentSubmissions = new HashSet<Submission>();
			SubmissionDetails = new HashSet<SubmissionDetail>();
		}
	}
}
