using System;
using System.Collections.Generic;

namespace DeviceRepair.Models
{
    public class DeviceWarrantyRequestFormView
    {
        /// <summary>
        /// 主键编号 (原则：300000000 - 399999999)
        ///</summary>
        public int AutoID { get; set; }
        /// <summary>
        /// 唯一编号 
        ///</summary>
        public Guid GUID { get; set; }
        /// <summary>
        /// 设备表主键编号 
        ///</summary>
        public int EquipmentPK { get; set; }
        /// <summary>
        /// 设备编号 
        ///</summary>
        public string EquipmentID { get; set; }
        /// <summary>
        /// 设备名称 
        ///</summary>
        public string EquipmentName { get; set; }
        /// <summary>
        /// 发生地点 
        ///</summary>
        public int Location { get; set; }
        /// <summary>
        /// 发生地点 
        ///</summary>
        public string LocationName { get; set; }
        /// <summary>
        /// 是否有在途生产单 
        ///</summary>
        public bool InProduction { get; set; }
        /// <summary>
        /// 批次号 
        ///</summary>
        public string Batch { get; set; }
        /// <summary>
        /// 故障现象
        /// </summary>
        public string FaultSymptoms { get; set; }
        /// <summary>
        /// 设备设施部
        /// </summary>
        public string ReceivingDep { get; set; }
        /// <summary>
        /// 停机状态（是、否）
        /// </summary>
        public bool IsDown { get; set; }
        /// <summary>
        /// 文档版本
        /// </summary>
        public int FormVer { get; set; }
        /// <summary>
        /// 申请时间 
        ///</summary>
        public DateTime? CreatOn { get; set; }
        /// <summary>
        /// 申请人 
        ///</summary>
        public int? CreatBy { get; set; }
        /// <summary>
        /// 申请人姓名
        /// </summary>
        public string CreatorName { get; set; }
        /// <summary>
        /// 修改时间 
        ///</summary>
        public DateTime? ModifyOn { get; set; }
        /// <summary>
        /// 修改人 
        ///</summary>
        public int? ModifyBy { get; set; }
        /// <summary>
        /// 修改人姓名
        /// </summary>
        public string ModifyByName { get; set; }

        public DateTime? RestorationConfirmationOn { get; set; }

        public int RestorationConfirmationBy { get; set; }

        public string RestorationConfirmationOnName { get; set; }

        public DeviceWarrantyRequestMaintaionView MaintaionItems { get; set; }

        public List<DeviceWarrantyEvaluatorInfo> EvaluatorItems { get; set; }


        public DeviceWarrantyRequestFormStatus FormStatus
        {
            get
            {
                if (MaintaionItems == null || MaintaionItems.SubmitBy == 0)
                {
                    return DeviceWarrantyRequestFormStatus.AwaitingRepair;
                }
                else if (MaintaionItems.SubmitBy > 0)
                {
                    if (RestorationConfirmationBy > 0)
                    {
                        return DeviceWarrantyRequestFormStatus.BeComplate;

                    }

                    return DeviceWarrantyRequestFormStatus.AwaitingApproval;
                }
               
                return DeviceWarrantyRequestFormStatus.AwaitingRepair;
            }
        }

        public string FormStatusText
        {
            get
            {
                return FormStatus.ToDescription();
            }
        }

        public string IsDownStatusText { get { return IsDown ? "停机" : "非停机"; } }
    }
}
