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

namespace Rainbow.Models
{
    public class Ticket : IAuditInfo
    {
        public Ticket()
        {
            Responses = new List<TicketResponse>();
        }

        public int Id { get; set; }

        [Required, Display(Name = "Titel")]
        public string Title { get; set; }

        [Display(Name = "Beschreibung")]
        public string Description { get; set; }

        [Display(Name = "Zugewiesen an")]
        public ApplicationUser AssignedTo { get; set; }

        [Required, Display(Name = "Status")]
        public TicketStatus Status { get; set; }

        [Required, Display(Name = "Priorität")]
        public TicketPriority Priority { get; set; }

        [Required, Display(Name = "Schweregrad")]
        public TicketSeverity Severity { get; set; }

        [Required, Display(Name = "Projekt")]
        public int ProjectId { get; set; }
        public virtual Project Project { get; set; }

        [Required, Display(Name = "Erstellt")]
        public DateTime Created { get; set; }

        [Display(Name = "Erstellt von")]
        public string CreatedBy { get; set; }

        [Required, Display(Name = "Geändert")]
        public DateTime LastModified { get; set; }

        [Display(Name = "Geändert von")]
        public string LastModifiedBy { get; set; }
        
        public virtual ICollection<TicketResponse> Responses { get; set; }

        public static Dictionary<int, string> GetStatusTextList()
        {
            var dict = new Dictionary<int, string>
            {
                {(int) TicketStatus.Open, "Offen"},
                {(int) TicketStatus.Assigned, "Zugewiesen"},
                {(int) TicketStatus.Resolved, "Behoben"},
                {(int) TicketStatus.Rejected, "Abgewiesen"},
                {(int) TicketStatus.Closed, "Geschlossen"}
            };
            return dict;
        }

        public static Dictionary<int, string> GetPriorityTextList()
        {
            var dict = new Dictionary<int, string>
            {
                {(int) TicketPriority.P1, "P1"},
                {(int) TicketPriority.P2, "P2"},
                {(int) TicketPriority.P3, "P3"}
            };
            return dict;
        }

        public static Dictionary<int, string> GetSeverityTextList()
        {
            var dict = new Dictionary<int, string>
            {
                {(int) TicketSeverity.Blocker, "Blockierung"},
                {(int) TicketSeverity.Critical, "Kritisch"},
                {(int) TicketSeverity.Major, "Wesentlich"},
                {(int) TicketSeverity.Normal, "Normal"},
                {(int) TicketSeverity.Minor, "Geringfügig"},
                {(int) TicketSeverity.Trivial, "Trivial"},
                {(int) TicketSeverity.Enhancement, "Kosmetisch"}
            };
            return dict;
        }
    }

    public enum TicketStatus
    {
        Open = 0,
        Assigned = 1,
        Resolved = 2,
        Rejected = 3,
        Closed = 4
    }

    public enum TicketPriority
    {
        P1,
        P2,
        P3
    }

    public enum TicketSeverity
    {
        Blocker,
        Critical,
        Major,
        Normal,
        Minor,
        Trivial,
        Enhancement
    }
}
