using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix { public class CategoryDataModel { public int Id { get; set; } public string Description { get; set; } public static CategoryDataModel FromCategory(Core.Domain.Appendix.Category categoryEntity, bool newWhenIsNull) { if (categoryEntity == null && newWhenIsNull) return new CategoryDataModel { Id = -1 }; if (categoryEntity == null && !newWhenIsNull) throw new ArgumentNullException("categoryEntity", "Cannot create CategoryDataModel from NULL category entity."); return new CategoryDataModel { Id = categoryEntity.Id, Description = categoryEntity.Description }; } public Core.Domain.Appendix.Category ToCategory() { return new Core.Domain.Appendix.Category { Id = this.Id, Description = this.Description }; } } }