using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix { public class StateDataModel { public int Id { get; set; } public string Description { get; set; } public string HexColor { get; set; } public bool IsZeroValue { get; set; } public bool IsDefault { get; set; } public bool IsFinish { get; set; } public decimal InitialPercentage { get; set; } public static StateDataModel FromState(Core.Domain.Appendix.State stateEntity, bool newWhenIsNull) { if (stateEntity == null && newWhenIsNull) return new StateDataModel { Id = -1 }; if (stateEntity == null && !newWhenIsNull) throw new ArgumentNullException("stateEntity", "Cannot create StateDataModel from NULL state entity."); return new StateDataModel { Id = stateEntity.Id, Description = stateEntity.Description, HexColor = stateEntity.HexColor, IsZeroValue = stateEntity.IsZeroValue, IsDefault = stateEntity.IsDefault, IsFinish = stateEntity.IsFinish, InitialPercentage = stateEntity.InitialPercentage }; } public Core.Domain.Appendix.State ToState() { return new Core.Domain.Appendix.State { Id = this.Id, Description = this.Description, HexColor = this.HexColor, IsZeroValue = this.IsZeroValue, IsDefault = this.IsDefault, IsFinish = this.IsFinish, InitialPercentage = this.InitialPercentage }; } } }