DisturbanceDataModel.cs 1.2 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 DisturbanceDataModel
  8. {
  9. public int Id { get; set; }
  10. public string Description { get; set; }
  11. public static DisturbanceDataModel FromDisturbance(Core.Domain.Deviation.Disturbance disturbanceEntity, bool newWhenIsNull)
  12. {
  13. if (disturbanceEntity == null && newWhenIsNull)
  14. return new DisturbanceDataModel
  15. {
  16. Id = -1
  17. };
  18. if (disturbanceEntity == null && !newWhenIsNull)
  19. throw new ArgumentNullException("disturbanceEntity", "Cannot create DisturbanceDataModel from NULL disturbance entity.");
  20. return new DisturbanceDataModel
  21. {
  22. Id = disturbanceEntity.Id,
  23. Description = disturbanceEntity.Description
  24. };
  25. }
  26. public Core.Domain.Deviation.Disturbance ToDisturbance()
  27. {
  28. return new Core.Domain.Deviation.Disturbance
  29. {
  30. Id = this.Id,
  31. Description = this.Description
  32. };
  33. }
  34. }
  35. }