RestaurantData.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*
  2. * Copyright © 2011-2012 Nokia Corporation. All rights reserved.
  3. * Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
  4. * Other product and company names mentioned herein may be trademarks
  5. * or trade names of their respective owners.
  6. * See LICENSE.TXT for license information.
  7. */
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Collections.ObjectModel;
  11. using System.ComponentModel;
  12. using System.Device.Location;
  13. namespace wprestaurantapp
  14. {
  15. /// <summary>
  16. /// Model class for restaurant data
  17. /// </summary>
  18. public class RestaurantData : INotifyPropertyChanged
  19. {
  20. /// <summary>
  21. /// Constructor
  22. /// </summary>
  23. public RestaurantData()
  24. {
  25. }
  26. /// <summary>
  27. /// Member variable for Name property
  28. /// </summary>
  29. private string _name;
  30. /// <summary>
  31. /// Property for name of the restaurant
  32. /// </summary>
  33. public string Name
  34. {
  35. get
  36. {
  37. return _name;
  38. }
  39. set
  40. {
  41. if (_name != value)
  42. {
  43. _name = value;
  44. NotifyPropertyChanged("Name");
  45. }
  46. }
  47. }
  48. /// <summary>
  49. /// Member variable for LogoURI property
  50. /// </summary>
  51. private string _logoURI;
  52. /// <summary>
  53. /// Property for URI to the restaurant logo
  54. /// </summary>
  55. public string LogoURI
  56. {
  57. get
  58. {
  59. return _logoURI;
  60. }
  61. set
  62. {
  63. if (_logoURI != value)
  64. {
  65. _logoURI = value;
  66. NotifyPropertyChanged("LogoURI");
  67. }
  68. }
  69. }
  70. /// <summary>
  71. /// Member variable for StreetAddress property
  72. /// </summary>
  73. private string _streetAddress;
  74. /// <summary>
  75. /// Property for street address of the restaurant
  76. /// </summary>
  77. public string StreetAddress
  78. {
  79. get
  80. {
  81. return _streetAddress;
  82. }
  83. set
  84. {
  85. if (_streetAddress != value)
  86. {
  87. _streetAddress = value;
  88. NotifyPropertyChanged("StreetAddress");
  89. }
  90. }
  91. }
  92. /// <summary>
  93. /// Member variable for City property
  94. /// </summary>
  95. private string _city;
  96. /// <summary>
  97. /// Property for city of the restaurant
  98. /// </summary>
  99. public string City
  100. {
  101. get
  102. {
  103. return _city;
  104. }
  105. set
  106. {
  107. if (_city != value)
  108. {
  109. _city = value;
  110. NotifyPropertyChanged("City");
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// Member variable for Country property
  116. /// </summary>
  117. private string _country;
  118. /// <summary>
  119. /// Property for country of the restaurant
  120. /// </summary>
  121. public string Country
  122. {
  123. get
  124. {
  125. return _country;
  126. }
  127. set
  128. {
  129. if (_country != value)
  130. {
  131. _country = value;
  132. NotifyPropertyChanged("Country");
  133. }
  134. }
  135. }
  136. /// <summary>
  137. /// Member variable for Location property
  138. /// </summary>
  139. private GeoCoordinate _location;
  140. /// <summary>
  141. /// Property for location of the restaurant
  142. /// </summary>
  143. public GeoCoordinate Location
  144. {
  145. get
  146. {
  147. if (_location == null)
  148. {
  149. // Set a default value other than NaN to location, Silverlight map control
  150. // wouldn't like it
  151. _location = new GeoCoordinate( 0.0, 0.0 );
  152. }
  153. return _location;
  154. }
  155. set
  156. {
  157. if (_location != value)
  158. {
  159. _location = value;
  160. NotifyPropertyChanged("Location");
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// Member variable for Telephone property
  166. /// </summary>
  167. private string _telephone;
  168. /// <summary>
  169. /// Property for telephone number of the restaurant
  170. /// </summary>
  171. public string Telephone
  172. {
  173. get
  174. {
  175. return _telephone;
  176. }
  177. set
  178. {
  179. if (_telephone != value)
  180. {
  181. _telephone = value;
  182. NotifyPropertyChanged("Telephone");
  183. }
  184. }
  185. }
  186. /// <summary>
  187. /// Member variable for URL property
  188. /// </summary>
  189. private string _url;
  190. /// <summary>
  191. /// Property for the website of the restaurant
  192. /// </summary>
  193. public string URL
  194. {
  195. get
  196. {
  197. return _url;
  198. }
  199. set
  200. {
  201. if (_url != value)
  202. {
  203. _url = value;
  204. NotifyPropertyChanged("URL");
  205. }
  206. }
  207. }
  208. /// <summary>
  209. /// Member variable for Description property
  210. /// </summary>
  211. private string _description;
  212. /// <summary>
  213. /// Property for description text of the restaurant
  214. /// </summary>
  215. public string Description
  216. {
  217. get
  218. {
  219. return _description;
  220. }
  221. set
  222. {
  223. if (_description != value)
  224. {
  225. _description = value;
  226. NotifyPropertyChanged("Description");
  227. }
  228. }
  229. }
  230. /// <summary>
  231. /// Member variable for Categories property
  232. /// </summary>
  233. private List<Category> _categories;
  234. /// <summary>
  235. /// Property for different categories of the restaurant
  236. /// </summary>
  237. public List<Category> Categories
  238. {
  239. get
  240. {
  241. if (_categories == null)
  242. {
  243. _categories = new List<Category>();
  244. }
  245. return _categories;
  246. }
  247. set
  248. {
  249. if (_categories != value)
  250. {
  251. _categories = value;
  252. NotifyPropertyChanged("Categories");
  253. }
  254. }
  255. }
  256. /// <summary>
  257. /// Member variable for Reservations property
  258. /// </summary>
  259. private ObservableCollection<Reservation> _reservations;
  260. /// <summary>
  261. /// Property for existing reservations of the restaurant
  262. /// </summary>
  263. public ObservableCollection<Reservation> Reservations
  264. {
  265. get
  266. {
  267. if (_reservations == null)
  268. {
  269. _reservations = new ObservableCollection<Reservation>();
  270. }
  271. return _reservations;
  272. }
  273. set
  274. {
  275. if (_reservations != value)
  276. {
  277. _reservations = value;
  278. NotifyPropertyChanged("Reservations");
  279. }
  280. }
  281. }
  282. /// <summary>
  283. /// Implementation of PropertyChanged event of INotifyPropertyChanged
  284. /// </summary>
  285. public event PropertyChangedEventHandler PropertyChanged;
  286. /// <summary>
  287. /// Helper method for emitting PropertyChanged event
  288. /// </summary>
  289. /// <param name="propertyName">Name of the property that has changed</param>
  290. private void NotifyPropertyChanged(String propertyName)
  291. {
  292. PropertyChangedEventHandler handler = PropertyChanged;
  293. if (null != handler)
  294. {
  295. handler(this, new PropertyChangedEventArgs(propertyName));
  296. }
  297. }
  298. }
  299. }