using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace FSI.Prj.Mgt.Models
{
    public class Organization
    {
        public Organization()
        {
            Parents = new HashSet<Organization>();
        }

        [Key]
        public int Id { get; set; }

        [DisplayName("Name")]
        [Required(ErrorMessage = "Namen eingeben.")]
        public string Name { get; set; }

        [DisplayName("Kurzname")]
        [Required(ErrorMessage = "Kurznamen eingeben.")]
        public string ShortName { get; set; }

        [DisplayName("Beschreibung")]
        public string? Description { get; set; }

        [ForeignKey("Id")]
        [DisplayName("übergeordnetes Element")]
        public int? ParentId { get; set; }

        public virtual Organization? Parent { get; set; }
        public virtual ICollection<Organization> Parents { get; set; }

        [DisplayName("Type")]
        [Required(ErrorMessage = "Typ muss angegeben werden.")]
        public OrganizationType Type { get; set; }

        [DisplayName("Erstellungsdatum")]        
        public DateTime CreationTimeStamp { get; set; }

        [DisplayName("Änderungsdatum")]
        public DateTime ModificationTimeStamp { get; set; }

        [DisplayName("vollständiger Kurzname")]        
        public string FullShortName { get; set; }
    
    }

    public enum OrganizationType
    {
        [Display(Name = "Firma")]
        company,
        [Display(Name = "Werk")]
        factory,
        [Display(Name = "Bereich")]
        area,
        [Display(Name = "Anlage")]
        plant,
        [Display(Name = "Teilanlage")]
        subPlant,
    }

}
