StateDataModel.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace GreenTree.Nachtragsmanagement.Web.Models.Appendix
  6. {
  7. public class StateDataModel
  8. {
  9. public int Id { get; set; }
  10. public string Description { get; set; }
  11. public string HexColor { get; set; }
  12. public bool IsZeroValue { get; set; }
  13. public bool IsDefault { get; set; }
  14. public bool IsFinish { get; set; }
  15. public static StateDataModel FromState(Core.Domain.Appendix.State stateEntity, bool newWhenIsNull)
  16. {
  17. if (stateEntity == null && newWhenIsNull)
  18. return new StateDataModel
  19. {
  20. Id = -1
  21. };
  22. if (stateEntity == null && !newWhenIsNull)
  23. throw new ArgumentNullException("stateEntity", "Cannot create StateDataModel from NULL state entity.");
  24. return new StateDataModel
  25. {
  26. Id = stateEntity.Id,
  27. Description = stateEntity.Description,
  28. HexColor = stateEntity.HexColor,
  29. IsZeroValue = stateEntity.IsZeroValue,
  30. IsDefault = stateEntity.IsDefault,
  31. IsFinish = stateEntity.IsFinish
  32. };
  33. }
  34. public Core.Domain.Appendix.State ToState()
  35. {
  36. return new Core.Domain.Appendix.State
  37. {
  38. Id = this.Id,
  39. Description = this.Description,
  40. HexColor = this.HexColor,
  41. IsZeroValue = this.IsZeroValue,
  42. IsDefault = this.IsDefault,
  43. IsFinish = this.IsFinish
  44. };
  45. }
  46. }
  47. }