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

using Fab2ApprovalSystem.ViewModels;

namespace Fab2ApprovalSystem.Models;

/// <summary>
/// 
/// </summary>
[Serializable]
public class MRB {

    public int MRBNumber { get; set; }
    public string Title { get; set; }
    public int MRBRaisedAreaID { get; set; }
    public int OriginatorID { get; set; }
    public int Owner { get; set; }
    public int Module { get; set; }
    public DateTime? MRBRaisedDate { get; set; }
    public string Process { get; set; }
    public int ApprovalStatus { get; set; }
    public string Tool { get; set; }
    public string ToolCSV { get; set; }
    public int NumberOfLotsAffected { get; set; }
    public int NumberOfWafersAffected { get; set; }
    public int NumberOfDiesAffected { get; set; }
    public DateTime? ApprovalDate { get; set; }
    public int CANo { get; set; }
    public string IssueDescription { get; set; }
    public DateTime? IssueDetectedDate { get; set; }
    public DateTime? IssueStartDate { get; set; }
    public DateTime? IssueEndDate { get; set; }

    // viewmodel
    public string OwnerName { get; set; }
    public List<int> PartGroupIDs { get; set; }
    public List<int> ModuleIDs { get; set; }
    public List<int> DispositionIDs { get; set; }
    public List<int> RiskAssessmentIDs { get; set; }
    public string Notes { get; set; }
    public string OwnerApprover { get; set; }
    public string MfgEngineeringAppover { get; set; }
    public string YEApprover { get; set; }
    public string PEApprover { get; set; }
    public string OtherApprovers { get; set; }
    public string QualityApprovers { get; set; }
    public byte CurrentStep { get; set; }
    public string DetailsFolder { get; set; }
    public bool CustomerImpacted { get; set; }
    public int WorkFlowNumber { get; set; }
    public string ApprovalStatusString {
        get {
            switch (ApprovalStatus) {
                case 0:
                    return "PENDING";
                case 1:
                    return "APPROVED";
                default:
                    return "CLOSED";
            }
        }
    }

    public MRB() {
        PartGroupIDs = new List<int>();
        ModuleIDs = new List<int>();
        DispositionIDs = new List<int>();
        RiskAssessmentIDs = new List<int>();
    }

}

public class PartGroup {

    public int PartGroupID { get; set; }
    public string PartGroupName { get; set; }

}

public class Module {

    public int ModuleID { get; set; }
    public string ModuleName { get; set; }

}

public class RiskAssessment {

    public int RiskAssessmentID { get; set; }
    public string RiskAssessmentName { get; set; }

}

public class Disposition {

    public int DispositionID { get; set; }
    public int MRBNumber { get; set; }
    [Display(Name = "Type")]
    public string DispositionType { get; set; }
    [Display(Name = "Dispo Desc")]
    public string DispositionName { get; set; }
    public string DispositionNotes { get; set; }

    // Duplicated as the CloseToQDBOptionID is being used in the dropdown in the Grid kept the old code
    public int CloseToQDBOption_ID { get; set; }

    [UIHint("CloseToQDBTemplate")]
    [Display(Name = "Close To QDB(Yes/No)")]
    public CloseToQDBOptionViewModel CloseToQDBOption { get; set; }

    [Display(Name = "MRB Flag to SPN")]
    public string CloseToQDBOptionString {
        get {
            switch (CloseToQDBOption_ID) {
                case 0:
                    return "No";
                case 1:
                    return "Yes";
                default:
                    return "No";
            }
        }
    }

}

public class MRBAttachment {

    public int AttachmentID { set; get; }
    public int MRBNumber { get; set; }
    public string FileName { get; set; }
    public int UserID { get; set; }
    // extrafield
    public string FullName { get; set; }
    public string UploadDate { get; set; }
    public string Path { get; set; }

}

public class ContainmentActionObj {

    public int ContainmentActionID { get; set; }
    public int MRBNumber { get; set; }
    public string ContainmentAction { get; set; }
    public int ResponsibilityOwnerID { get; set; }
    public int CurrentResponsibilityOwnerID { get; set; }
    public string ResponsibilityOwner { get; set; }

    public DateTime? ECD { get; set; }

    [DataType(DataType.Date)]
    public DateTime? ImplementedDate { get; set; }

}

public class SPN_MRB {

    public int MRBNumber;
    public char? DispoType;

}