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

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

        /// <summary>
        /// Disturbance values related to the deviation
        /// </summary>
        private ICollection<DisturbanceValue> _disturbanceValues;

        #endregion

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

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

        /// <summary>
        /// Date when deviation were created
        /// </summary>
        public DateTime? ReceiptDate { get; set; }

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

        /// <summary>
        /// Monetary value
        /// </summary>
        public decimal? Value { get; set; }

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

        /// <summary>
        /// Id of corresponding appendix
        /// </summary>
        public int? AppendixId { get; set; }

        /// <summary>
        /// Corresponding appendix
        /// </summary>
        public virtual Appendix.Appendix Appendix { get; set; }

        /// <summary>
        /// Date when deviation was matched to a an appendix
        /// </summary>
        public DateTime? AppendixDate { 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>
        /// Id of the current deviation status
        /// </summary>
        public int? StatusId { get; set; }

        /// <summary>
        /// Current deviation status
        /// </summary>
        public virtual Status Status { get; set; }

        /// <summary>
        /// Id of the current deviation kind
        /// </summary>
        public int? KindId { get; set; }

        /// <summary>
        /// Current deviation kind
        /// </summary>
        public virtual Kind Kind { get; set; }

        /// <summary>
        /// Disturbances values related to the deviation
        /// </summary>
        public virtual ICollection<DisturbanceValue> DisturbanceValues
        {
            get { return _disturbanceValues ?? (_disturbanceValues = new List<DisturbanceValue>()); }
            protected set { _disturbanceValues = value; }
        }

        #region Helper

        public void SetDisturbanceValues(ICollection<DisturbanceValue> disturbanceValues)
        {
            DisturbanceValues = disturbanceValues;
        }

        #endregion
    }
}
