Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.ComponentModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace GOT_PTTK_PRACOWNIK.Model
  10. {
  11. public class OdznakaModel : INotifyPropertyChanged
  12. {
  13. private long id;
  14. private string stopien;
  15. private string rodzaj;
  16. private ObservableCollection<WycieczkaModel> wycieczki;
  17. private bool czyZweryfikowana;
  18. private string imgPath;
  19. private int minPkt;
  20.  
  21. public long Id
  22. {
  23. get
  24. {
  25. return id;
  26. }
  27. set
  28. {
  29. if(id!=value)
  30. {
  31. id = value;
  32. RaisePropertyChanged("Id");
  33. }
  34. }
  35. }
  36.  
  37. public string Stopien
  38. {
  39. get
  40. {
  41. return stopien;
  42. }
  43. set
  44. {
  45. if(stopien!=value)
  46. {
  47. stopien = value;
  48. RaisePropertyChanged("Stopien");
  49. }
  50. }
  51. }
  52.  
  53. public string Rodzaj
  54. {
  55. get
  56. {
  57. return rodzaj;
  58. }
  59. set
  60. {
  61. if (rodzaj != value)
  62. {
  63. rodzaj = value;
  64. RaisePropertyChanged("Rodzaj");
  65. }
  66. }
  67. }
  68.  
  69. public bool CzyZweryfikowana
  70. {
  71. get
  72. {
  73. return czyZweryfikowana;
  74. }
  75. set
  76. {
  77. if (czyZweryfikowana != value)
  78. {
  79. czyZweryfikowana = value;
  80. RaisePropertyChanged("CzyZweryfikowana");
  81. }
  82. }
  83. }
  84.  
  85. public string ImgPath
  86. {
  87. get
  88. {
  89. return imgPath;
  90. }
  91. set
  92. {
  93. if (imgPath != value)
  94. {
  95. imgPath = value;
  96. RaisePropertyChanged("ImgPath");
  97. }
  98. }
  99. }
  100.  
  101. public int Pkt
  102. {
  103. get
  104. {
  105. int suma = 0;
  106. foreach(WycieczkaModel wycieczka in wycieczki)
  107. {
  108. if (wycieczka.Status == StatusyPotwierdzenia.POTWIERDZONA)
  109. suma += wycieczka.Punktacja;
  110. }
  111. return suma;
  112. }
  113. set
  114. {
  115. if (minPkt != value)
  116. {
  117. minPkt = value;
  118. RaisePropertyChanged("Pkt");
  119. }
  120. }
  121. }
  122.  
  123. public int MinPkt
  124. {
  125. get
  126. {
  127. return minPkt;
  128. }
  129. set
  130. {
  131. if (minPkt != value)
  132. {
  133. minPkt = value;
  134. RaisePropertyChanged("MinPkt");
  135. }
  136. }
  137. }
  138.  
  139. public ObservableCollection<WycieczkaModel> Wycieczki
  140. {
  141. get;
  142. }
  143.  
  144. public TurystaModel Turysta { get; }
  145.  
  146. public OdznakaModel(ref TurystaModel turysta)
  147. {
  148. Turysta = turysta;
  149. wycieczki = new ObservableCollection<WycieczkaModel>();
  150.  
  151. }
  152.  
  153. public void DodajWycieczke(WycieczkaModel wycieczka)
  154. {
  155. wycieczki.Add(wycieczka);
  156. }
  157.  
  158. public void UsunWycieczke(WycieczkaModel wycieczka)
  159. {
  160. wycieczki.Remove(wycieczka);
  161. }
  162.  
  163. public event PropertyChangedEventHandler PropertyChanged;
  164.  
  165. public void RaisePropertyChanged(string property)
  166. {
  167. if (PropertyChanged != null)
  168. {
  169. PropertyChanged(this, new PropertyChangedEventArgs(property));
  170. }
  171. }
  172.  
  173. private bool CzyWarunkiSpelnione()
  174. {
  175. return Pkt >= MinPkt;
  176. }
  177.  
  178. }
  179. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement