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