StatusDataModel.cs 1.6 KB

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