StatusDataModel.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 StatusDataModel
  8. {
  9. public int Id { get; set; }
  10. public string Description { get; set; }
  11. public bool IsDefault { get; set; }
  12. public bool IsZeroValue { get; set; }
  13. public static StatusDataModel FromStatus(Core.Domain.Deviation.Status statusEntity, bool newWhenIsNull)
  14. {
  15. if (statusEntity == null && newWhenIsNull)
  16. return new StatusDataModel
  17. {
  18. Id = -1
  19. };
  20. if (statusEntity == null && !newWhenIsNull)
  21. throw new ArgumentNullException("statusEntity", "Cannot create StatusDataModel from NULL status entity.");
  22. return new StatusDataModel
  23. {
  24. Id = statusEntity.Id,
  25. Description = statusEntity.Description,
  26. IsDefault = statusEntity.IsDefault,
  27. IsZeroValue = statusEntity.IsZeroValue
  28. };
  29. }
  30. public Core.Domain.Deviation.Status ToStatus()
  31. {
  32. return new Core.Domain.Deviation.Status
  33. {
  34. Id = this.Id,
  35. Description = this.Description,
  36. IsDefault = this.IsDefault,
  37. IsZeroValue = this.IsZeroValue
  38. };
  39. }
  40. }
  41. }