using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace PSTW_CentralSystem.Areas.IT.Models
{
    [Table("it_requests")]
    public class ItRequest
    {
        [Key]
        public int ItRequestId { get; set; }

        public int UserId { get; set; }   // FK -> aspnetusers.Id

        // snapshot fields (taken at submission time)
        [Required]
        [MaxLength(200)]
        public string StaffName { get; set; } = string.Empty;

        [MaxLength(200)]
        public string? CompanyName { get; set; }

        [MaxLength(200)]
        public string? DepartmentName { get; set; }

        [MaxLength(200)]
        public string? Designation { get; set; }

        [MaxLength(200)]
        public string? Location { get; set; }

        [MaxLength(50)]
        public string? EmploymentStatus { get; set; } // Permanent / Contract / Temp / New Staff

        public DateTime? ContractEndDate { get; set; }

        public DateTime RequiredDate { get; set; }

        [MaxLength(20)]
        public string? PhoneExt { get; set; }

        public DateTime SubmitDate { get; set; }

        // navigation
        public ICollection<ItRequestHardware> Hardware { get; set; } = new List<ItRequestHardware>();
        public ICollection<ItRequestEmail> Emails { get; set; } = new List<ItRequestEmail>();
        public ICollection<ItRequestOsRequirement> OsRequirements { get; set; } = new List<ItRequestOsRequirement>();
        public ICollection<ItRequestSoftware> Software { get; set; } = new List<ItRequestSoftware>();
        public ICollection<ItRequestSharedPermission> SharedPermissions { get; set; } = new List<ItRequestSharedPermission>();

        public DateTime? FirstSubmittedAt { get; set; }   // when the request was first created
        public DateTime? EditableUntil { get; set; }      // FirstSubmittedAt + window
        public bool IsLockedForEdit { get; set; }
    }
}
