KindDataModel.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace GreenTree.Nachtragsmanagement.Web.Models.Deviation
  6. {
  7. public class KindDataModel
  8. {
  9. public int Id { get; set; }
  10. public string Description { get; set; }
  11. public static KindDataModel FromKind(Core.Domain.Deviation.Kind kindEntity, bool newWhenIsNull)
  12. {
  13. if (kindEntity == null && newWhenIsNull)
  14. return new KindDataModel
  15. {
  16. Id = -1
  17. };
  18. if (kindEntity == null && !newWhenIsNull)
  19. throw new ArgumentNullException("kindEntity", "Cannot create KindDataModel from NULL kind entity.");
  20. return new KindDataModel
  21. {
  22. Id = kindEntity.Id,
  23. Description = kindEntity.Description
  24. };
  25. }
  26. public Core.Domain.Deviation.Kind ToKind()
  27. {
  28. return new Core.Domain.Deviation.Kind
  29. {
  30. Id = this.Id,
  31. Description = this.Description
  32. };
  33. }
  34. }
  35. }