StateDataModel.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 IsDefault { get; set; }
  13. public bool IsFinish { get; set; }
  14. public static StateDataModel FromState(Core.Domain.Appendix.State stateEntity, bool newWhenIsNull)
  15. {
  16. if (stateEntity == null && newWhenIsNull)
  17. return new StateDataModel
  18. {
  19. Id = -1
  20. };
  21. if (stateEntity == null && !newWhenIsNull)
  22. throw new ArgumentNullException("stateEntity", "Cannot create StateDataModel from NULL state entity.");
  23. return new StateDataModel
  24. {
  25. Id = stateEntity.Id,
  26. Description = stateEntity.Description,
  27. HexColor = stateEntity.HexColor,
  28. IsDefault = stateEntity.IsDefault,
  29. IsFinish = stateEntity.IsFinish
  30. };
  31. }
  32. public Core.Domain.Appendix.State ToState()
  33. {
  34. return new Core.Domain.Appendix.State
  35. {
  36. Id = this.Id,
  37. Description = this.Description,
  38. HexColor = this.HexColor,
  39. IsDefault = this.IsDefault,
  40. IsFinish = this.IsFinish
  41. };
  42. }
  43. }
  44. }