StateDataModel.cs 1.8 KB

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