KindDataModel.cs 1.2 KB

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