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

namespace GreenTree.Nachtragsmanagement.Web.Models.Deviation
{
    public class StatusDataModel
    {
        public int Id { get; set; }
        public string Description { get; set; }
        public bool IsDefault { get; set; }
        public bool IsZeroValue { get; set; }
        public bool IsZeroSummarize { get; set; }

        public static StatusDataModel FromStatus(Core.Domain.Deviation.Status statusEntity, bool newWhenIsNull)
        {
            if (statusEntity == null && newWhenIsNull)
                return new StatusDataModel
                {
                    Id = -1
                };

            if (statusEntity == null && !newWhenIsNull)
                throw new ArgumentNullException("statusEntity", "Cannot create StatusDataModel from NULL status entity.");

            return new StatusDataModel
            {
                Id = statusEntity.Id,
                Description = statusEntity.Description,
                IsDefault = statusEntity.IsDefault,
                IsZeroValue = statusEntity.IsZeroValue,
                IsZeroSummarize = statusEntity.IsZeroSummarize
            };
        }

        public Core.Domain.Deviation.Status ToStatus()
        {
            return new Core.Domain.Deviation.Status
            {
                Id = this.Id,
                Description = this.Description,
                IsDefault = this.IsDefault,
                IsZeroValue = this.IsZeroValue,
                IsZeroSummarize = this.IsZeroSummarize
            };
        }
    }
}