AccountViewModel.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. using AIPractice.LabellerServer.Managers.Entities;
  2. using System;
  3. namespace AIPractice.LabellerServer.ViewModels
  4. {
  5. public class AccountViewModel : ViewModel
  6. {
  7. private string _name;
  8. private string _password;
  9. private string _id;
  10. private DateTime _createdTime;
  11. private bool _isSelected;
  12. private string _labels;
  13. private string _description;
  14. private bool _isReviewer;
  15. private string _email;
  16. public Account Account => new Account() { Id = Id, Name = Name, Password = Password, Description = string.IsNullOrEmpty(Description)? null:Description.Trim(), CreatedTime= CreatedTime, Labels = Labels, IsReviewer = IsReviewer, Email = Email};
  17. public event EventHandler IsSelectedChanged;
  18. public bool IsSelected
  19. {
  20. get => _isSelected;
  21. set
  22. {
  23. if (_isSelected != value)
  24. {
  25. _isSelected = value;
  26. OnIsSelectedChanged();
  27. OnPropertyChanged();
  28. }
  29. }
  30. }
  31. public string Id
  32. {
  33. get => _id;
  34. set
  35. {
  36. if (_id != value)
  37. {
  38. _id = value;
  39. OnPropertyChanged();
  40. }
  41. }
  42. }
  43. public string Name
  44. {
  45. get => _name;
  46. set
  47. {
  48. if (_name != value)
  49. {
  50. _name = value;
  51. OnPropertyChanged();
  52. }
  53. }
  54. }
  55. public string Password
  56. {
  57. get => _password;
  58. set
  59. {
  60. _password = value;
  61. OnPropertyChanged();
  62. }
  63. }
  64. public string Description
  65. {
  66. get => _description;
  67. set
  68. {
  69. if (_description != value)
  70. {
  71. _description = value;
  72. OnPropertyChanged();
  73. }
  74. }
  75. }
  76. public DateTime CreatedTime
  77. {
  78. get => _createdTime;
  79. set
  80. {
  81. if (_createdTime != value)
  82. {
  83. _createdTime = value;
  84. OnPropertyChanged();
  85. }
  86. }
  87. }
  88. public string Labels
  89. {
  90. get => _labels;
  91. set
  92. {
  93. if (_labels != value)
  94. {
  95. _labels = value;
  96. OnPropertyChanged();
  97. }
  98. }
  99. }
  100. public bool IsReviewer
  101. {
  102. get => _isReviewer;
  103. set
  104. {
  105. if (_isReviewer != value)
  106. {
  107. _isReviewer = value;
  108. OnPropertyChanged();
  109. }
  110. }
  111. }
  112. public string FriendlyName
  113. {
  114. get
  115. {
  116. if (string.IsNullOrEmpty(Description))
  117. {
  118. return Name;
  119. }
  120. return Description;
  121. }
  122. }
  123. public string Email
  124. {
  125. get => _email;
  126. set
  127. {
  128. if (_email != value)
  129. {
  130. _email = value;
  131. OnPropertyChanged();
  132. }
  133. }
  134. }
  135. public AccountViewModel Clone()
  136. {
  137. return new AccountViewModel
  138. {
  139. Id = Id,
  140. Name = Name,
  141. Password = Password,
  142. Description = string.IsNullOrEmpty(Description) ? null : Description.Trim(),
  143. CreatedTime = CreatedTime,
  144. Labels = Labels,
  145. IsReviewer = IsReviewer,
  146. Email = Email,
  147. };
  148. }
  149. private void OnIsSelectedChanged()
  150. {
  151. IsSelectedChanged?.Invoke(this, EventArgs.Empty);
  152. }
  153. }
  154. }