using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GreenTree.Nachtragsmanagement.Core.Domain.Appendix
{
    public class Appendix : BaseEntity
    {
        #region Fields

        /// <summary>
        /// Categories values related to the appendix
        /// </summary>
        private ICollection<CategoryValue> _categoryValues;

        /// <summary>
        /// Deviations related to the appendix
        /// </summary>
        private ICollection<Deviation.Deviation> _deviations;

        /// <summary>
        /// Invoices related to the appendix
        /// </summary>
        private ICollection<Invoice.Invoice> _invoices;

        #endregion

        /// <summary>
        /// Customized number for identification
        /// </summary>
        public string CustomNumber { get; set; }

        /// <summary>
        /// The lot
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// Monetary value of all corresponding deviations
        /// </summary>
        public decimal? Value { get; set; }

        /// <summary>
        /// Montary percentage value
        /// </summary>
        public decimal? Percentage { get; set; }

        /// <summary>
        /// Number of corresponding offer
        /// </summary>
        public int? OfferingNumber { get; set; }

        /// <summary>
        /// Date when corresponding offer was created
        /// </summary>
        public DateTime? OfferingDate { get; set; }

        /// <summary>
        /// Date of negotiation
        /// </summary>
        public DateTime? NegotiationDate { get; set; }

        /// <summary>
        /// Value of negotiation
        /// </summary>
        public decimal? NegotiationValue { get; set; }

        /// <summary>
        /// Determines if protocol exists
        /// </summary>
        public bool ProtocolExists { get; set; }

        /// <summary>
        /// Determines if an order invoice has been created
        /// </summary>
        public bool OrderInvoiceCreated { get; set; }

        /// <summary>
        /// Number of the corresponding order
        /// </summary>
        public string OrderNumber { get; set; }

        /// <summary>
        /// Date of the corresponding order
        /// </summary>
        public DateTime? OrderDate { get; set; }

        /// <summary>
        /// Editable comment
        /// </summary>
        public string Comment { get; set; }

        /// <summary>
        /// Id of corresponding state
        /// </summary>
        public int? StateId { get; set; }

        /// <summary>
        /// Corresponding site
        /// </summary>
        public virtual State State { get; set; }

        /// <summary>
        /// Id of corresponding site
        /// </summary>
        public int? SiteId { get; set; }

        /// <summary>
        /// Corresponding site
        /// </summary>
        public virtual Site.Site Site { get; set; }

        /// <summary>
        /// Category values related to the appendix
        /// </summary>
        public virtual ICollection<CategoryValue> CategoryValues
        {
            get { return _categoryValues ?? (_categoryValues = new List<CategoryValue>()); }
            protected set { _categoryValues = value; }
        }

        /// <summary>
        /// Deviations related to the appendix
        /// </summary>
        public virtual ICollection<Deviation.Deviation> Deviations
        {
            get { return _deviations ?? ( _deviations = new List<Deviation.Deviation>()); }
            protected set { _deviations = value; }
        }

        /// <summary>
        /// Invoices related to the appendix
        /// </summary>
        public virtual ICollection<Invoice.Invoice> Invoices
        {
            get { return _invoices ?? (_invoices = new List<Invoice.Invoice>()); }
            protected set { _invoices = value; }
        }

        #region Helper

        public void SetCategoryValues(ICollection<CategoryValue> categoryValues)
        {
            CategoryValues = categoryValues;
        }

        #endregion
    }
}
