KindDataModel.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 string Shortance { get; set; }
  12. public bool IsDefault { get; set; }
  13. public static KindDataModel FromKind(Core.Domain.Deviation.Kind kindEntity, bool newWhenIsNull)
  14. {
  15. if (kindEntity == null && newWhenIsNull)
  16. return new KindDataModel
  17. {
  18. Id = -1
  19. };
  20. if (kindEntity == null && !newWhenIsNull)
  21. throw new ArgumentNullException("kindEntity", "Cannot create KindDataModel from NULL kind entity.");
  22. return new KindDataModel
  23. {
  24. Id = kindEntity.Id,
  25. Description = kindEntity.Description,
  26. Shortance = kindEntity.Shortance,
  27. IsDefault = kindEntity.IsDefault
  28. };
  29. }
  30. public Core.Domain.Deviation.Kind ToKind()
  31. {
  32. return new Core.Domain.Deviation.Kind
  33. {
  34. Id = this.Id,
  35. Description = this.Description,
  36. Shortance = this.Shortance,
  37. IsDefault = this.IsDefault
  38. };
  39. }
  40. }
  41. }