using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace GreenTree.Nachtragsmanagement.Web.Models.Deviation
{
    public class DisturbanceDataModel
    {
        public int Id { get; set; }
        public string Description { get; set; }

        public static DisturbanceDataModel FromDisturbance(Core.Domain.Deviation.Disturbance disturbanceEntity, bool newWhenIsNull)
        {
            if (disturbanceEntity == null && newWhenIsNull)
                return new DisturbanceDataModel
                {
                    Id = -1
                };

            if (disturbanceEntity == null && !newWhenIsNull)
                throw new ArgumentNullException("disturbanceEntity", "Cannot create DisturbanceDataModel from NULL disturbance entity.");

            return new DisturbanceDataModel
            {
                Id = disturbanceEntity.Id,
                Description = disturbanceEntity.Description
            };
        }

        public Core.Domain.Deviation.Disturbance ToDisturbance()
        {
            return new Core.Domain.Deviation.Disturbance
            {
                Id = this.Id,
                Description = this.Description
            };
        }
    }
}