using Fab2ApprovalSystem.ViewModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Script.Serialization;

namespace Fab2ApprovalSystem.Models
{

  
    [Serializable]
    public class LotDisposition 
    {
        //[Editable(false)]
        [Display(Name = "Issue Number")]
        public int IssueID { get; set; }
        //[Editable(false)]
        public string Title { get; set; }
        public bool PERequired { get; set; }       
        public string IssueDescription { get; set; }
        [ReadOnly(true)]
        public DateTime? IssueDate { get; set; }
        public DateTime? SubmitedDate { get; set; }
        public DateTime? CloseDate { get; set; }
        public int OriginatorID { get; set; }
        public string OriginatorName { get; set; }
        public string ReasonForDisposition { get; set; }
        public int ResponsibilityID { get; set; }
        public int ResponsibilityIssueID { get; set; }
        public string SPNScrapCode { get; set; }
        public byte CurrentStep { get; set; }
        // Extra field Defined for Scraping wafer for a given lot
        public Lot Lot { get; set; }
        //Extra field defined for Attachments
        public Attachment DocumentAttachment { get; set; }
        
        // important!!make sure the id of the control matches the name of the field in the model  it is being binded to, 
        // in order to get the selected items from the control
        public List<int> DepartmentIDs { get; set; }

        public List<Attachment> Attachments { get; set; }
        public List<Approval> Approvals { get; set; }
        public List<ScrapLot> ScrapLots { get; set; }

        public int CANo { get; set; }
        [Display(Name = "MRB Required")]
        public bool MRBRequired { get; set; }
        public int WorkFlowNumber { get; set; }

        [Display(Name = "Dispositon By OCAP")]
        public bool DispositionByOCAP { get; set; }

        public bool RecordLockIndicator { get; set; }
        public int RecordLockedBy { get; set; }
        public string RecordLockByName { get; set; }
        public DateTime? RecordLockedDate { get; set; }
        public int LastUpdatedBy { get; set; }
        public DateTime? LastUpdateDate { get; set; }

        


        public LotDisposition()
        {
            DepartmentIDs = new List<int>();
            Lot = new Lot();
            DocumentAttachment = new Attachment();
            //Lots = new List<Lot>();
            Attachments = new List<Attachment>();
            Approvals = new List<Approval>();
            ScrapLots = new List<ScrapLot>();
            IssueDate = DateTime.Now;
            CurrentStep = 0;
        }


    }

    //public class Lot
    //{
    //    public int LotID { get; set; }
    //    [Display(Name = "Wafer Lot#")]
    //    public string LotNumber { get; set; }
    //    public string ParentLotNumber { get { return LotNumber.Length >= 7 ? LotNumber.Substring(0, 7) : LotNumber; } }

    //    public int MRBNumber { get; set; }
    //    public int IssueID { get; set; }
    //    public string DieLotNumber { get; set; }
    //    public string Description { get; set; }
    //    [Display(Name="New PN#")]
    //    public string NewPartNo { get; set; }
    //    [Display(Name = "WIP PN#")]
    //    public string WipPartNo { get; set; }
    //    [Display(Name = "Die PN#")]
    //    public string DiePartNo { get; set; }
    //    [Display(Name="Family")]
    //    public string ProductFamily { get; set; }
    //    public double Gen { get; set; }
    //    public string Channel { get; set; }
    //    public double Hexsize { get; set; }
    //    public double Voltage { get; set; }
    //    public int WaferCount { get; set; }
    //    public int ReleaseCount { get; set; }
    //    public int ScrapCount { get; set; }
    //    public int DieCount { get; set; }
    //    public string Location { get; set; }
    //    public double TotalCost { get; set; }
    //    public int LotStatusOptionID { get; set; }
    //    public string LotStatusOptionName { get; set; }
    //    public double WaferCost { get; set; }
    //    public double DieCost { get; set; }

    //   [UIHint("LotStatusOptionTemplate")]
    //    [Display(Name="Lot Status")]
    //    public LotStatusOptionViewModel LotStatusOption { get; set; }

    //   public ScrapLot ScrapLotWafer { get; set; }
      

    //   public Lot()
    //   {
    //       LotStatusOption = new LotStatusOptionViewModel();
    //       ScrapLotWafer = new ScrapLot();
    //   }

    //}

    public class LotDispoDepartment
    {
        //public int LotDispoDepartmentID { get; set; }
        //public int IssueID { get; set; }
        public int DepartmentID { get; set; }
        public string DepartmentName { get; set; }
    }

    public class Attachment
    {
        public int AttachmentID { set; get; }
        public int IssueID { 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 Approval 
    {
        public int ApprovalID { get; set; }
        public int IssueID { get; set; }
        string StateName { get; set; }
        public int UserID { get; set; }
        public int SubRoleID { get; set; }
        public int ItemStatus { get; set; }
        public int Step { get; set; }
        public DateTime? NotifyDate { get; set; }
        public DateTime? AssignedDate { get; set; }
        public DateTime? RoleAssignedDate { get; set; }
        public DateTime? CompleteDateTime { get; set; }
        public string UserComments { get; set; }
    }


    public class ScrapLot 
    {

        
        public string LotNo { get; set; }        
        public int IssueID { get; set; }
        public int ScrapCount { get; set; }
        public int ReleaseCount { get; set; }
        public int SplitOfHoldCount { get; set; }
        public int CloseToQDBCount { get; set; }

        // extra field ( a viewmodel can be created)
        public int WaferCount { get; set; }

        public byte Lot1State { get; set; }
        public byte Lot2State { get; set; }
        public byte Lot3State { get; set; }
        public byte Lot4State { get; set; }
        public byte Lot5State { get; set; }
        public byte Lot6State { get; set; }
        public byte Lot7State { get; set; }
        public byte Lot8State { get; set; }
        public byte Lot9State { get; set; }
        public byte Lot10State { get; set; }
        public byte Lot11State { get; set; }
        public byte Lot12State { get; set; }
        public byte Lot13State { get; set; }
        public byte Lot14State { get; set; }
        public byte Lot15State { get; set; }
        public byte Lot16State { get; set; }
        public byte Lot17State { get; set; }
        public byte Lot18State { get; set; }
        public byte Lot19State { get; set; }
        public byte Lot20State { get; set; }
        public byte Lot21State { get; set; }
        public byte Lot22State { get; set; }
        public byte Lot23State { get; set; }
        public byte Lot24State { get; set; }
        public byte Lot25State { get; set; }
        public byte Lot26State { get; set; }
        public byte Lot27State { get; set; }
        public byte Lot28State { get; set; }
        public byte Lot29State { get; set; }
        public byte Lot30State { get; set; }
        public byte Lot31State { get; set; }
        public byte Lot32State { get; set; }
        public byte Lot33State { get; set; }
        public byte Lot34State { get; set; }
        public byte Lot35State { get; set; }
        public byte Lot36State { get; set; }
        public byte Lot37State { get; set; }
        public byte Lot38State { get; set; }
        public byte Lot39State { get; set; }
        public byte Lot40State { get; set; }
        public byte Lot41State { get; set; }
        public byte Lot42State { get; set; }
        public byte Lot43State { get; set; }
        public byte Lot44State { get; set; }
        public byte Lot45State { get; set; }
        public byte Lot46State { get; set; }
        public byte Lot47State { get; set; }
        public byte Lot48State { get; set; }
        public byte Lot49State { get; set; }
        public byte Lot50State { get; set; }
 
    }

    /// <summary>
    /// 
    /// </summary>
    public class Users
    {
        public int OriginatorID { get; set; }
        public string Originatorname { get;set;}
    
    }

    /// <summary>
    /// 
    /// </summary>
    public class Responsibility
    {
        public int ResponsibilityID { get; set; }
        public string ResponsibilityName { get; set; }
    }


    /// <summary>
    /// 
    /// </summary>
    public class ResponsibilityIssue
    {
        public int ResponsibilityIssueID { get; set; }
        public string Issue { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class Comments
    {
        public int ID { get; set; }
        public int IssueID  {get; set;}
        public string CommentedBy { get; set; }
        public string UserName{ get; set; }
        public string UserComments { get; set; }
        public DateTime TimeStamp { get; set; }

    }

}