StateDataModel.cs 1.1 KB

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