StatusDataModel.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. namespace GreenTree.Nachtragsmanagement.Web.Models.Deviation
  6. {
  7. public class StatusDataModel
  8. {
  9. public int Id { get; set; }
  10. public string Description { get; set; }
  11. public bool IsDefault { get; set; }
  12. public static StatusDataModel FromStatus(Core.Domain.Deviation.Status statusEntity, bool newWhenIsNull)
  13. {
  14. if (statusEntity == null && newWhenIsNull)
  15. return new StatusDataModel
  16. {
  17. Id = -1
  18. };
  19. if (statusEntity == null && !newWhenIsNull)
  20. throw new ArgumentNullException("statusEntity", "Cannot create StatusDataModel from NULL status entity.");
  21. return new StatusDataModel
  22. {
  23. Id = statusEntity.Id,
  24. Description = statusEntity.Description,
  25. IsDefault = statusEntity.IsDefault
  26. };
  27. }
  28. public Core.Domain.Deviation.Status ToStatus()
  29. {
  30. return new Core.Domain.Deviation.Status
  31. {
  32. Id = this.Id,
  33. Description = this.Description,
  34. IsDefault = this.IsDefault
  35. };
  36. }
  37. }
  38. }