PhoneClass.cs 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Formats.Asn1;
  5. using System.Globalization;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Runtime.Serialization;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using CsvHelper;
  12. namespace wpf_template.Model
  13. {
  14. [DataContract]
  15. public class Product
  16. {
  17. [DataMember]
  18. public string Title { get; set; }
  19. [DataMember]
  20. public string Company { get; set; }
  21. [DataMember]
  22. public int Price { get; set; }
  23. [DataMember]
  24. public string Category { get; set; }
  25. [DataMember]
  26. public bool Existence { get; set; }
  27. [DataMember(Name = "ArrivalDate")]
  28. private string? stringArrivalDate { get; set; }
  29. [IgnoreDataMember]
  30. public DateOnly? ArrivalDate
  31. {
  32. get
  33. {
  34. return stringArrivalDate == null ? null : DateOnly.Parse(stringArrivalDate);
  35. }
  36. set
  37. {
  38. stringArrivalDate = value.ToString();
  39. }
  40. }
  41. [DataMember]
  42. public double Rating { get; set; }
  43. [DataMember]
  44. public string Photo { get; set; }
  45. [IgnoreDataMember]
  46. public string ExistenceString
  47. {
  48. get {
  49. return Existence ? "Да" : "Нет";
  50. }
  51. }
  52. }
  53. public class ProductCategory
  54. {
  55. public string title { get; set; }
  56. }
  57. public class ProductPrice
  58. {
  59. public string title { get; set; }
  60. public int priceFrom { get; set; }
  61. public int priceTo { get; set; }
  62. }
  63. public class ProductCompany
  64. {
  65. public string title { get; set; }
  66. }
  67. interface IDataProvider
  68. {
  69. IEnumerable<Product> GetProducts();
  70. IEnumerable<ProductCategory> GetCategories();
  71. IEnumerable<ProductPrice> GetPrices();
  72. IEnumerable<ProductCompany> GetCompanies();
  73. }
  74. public class LocalDataProvider : IDataProvider
  75. {
  76. public IEnumerable<Product> GetProducts()
  77. {
  78. return new Product[]{
  79. new Product
  80. {
  81. Category = "Смартфон",
  82. Company = "Apple",
  83. Title = "13 Pro Max",
  84. Price = 84999
  85. },
  86. new Product
  87. {
  88. Category = "Смартфон",
  89. Company = "Samsung",
  90. Title = "S23",
  91. Price = 89999
  92. },
  93. new Product
  94. {
  95. Category = "Смартфон",
  96. Company = "Huawei",
  97. Title = "Nova Y61",
  98. Price = 9999
  99. },
  100. new Product
  101. {
  102. Category = "Смартфон",
  103. Company = "POCO",
  104. Title = "C51",
  105. Price = 5599
  106. },
  107. new Product
  108. {
  109. Category = "Ноутбук",
  110. Company = "Xiaomi",
  111. Title = "RedmiBook 15",
  112. Price = 49999
  113. },
  114. new Product
  115. {
  116. Category = "Ноутбук",
  117. Company = "Asus",
  118. Title = "Vivobook Go 15",
  119. Price = 25999
  120. },
  121. new Product
  122. {
  123. Category = "Ноутбук",
  124. Company = "Lenovo",
  125. Title = "IdeaPad 1",
  126. Price = 24999
  127. },
  128. new Product
  129. {
  130. Category = "Ноутбук",
  131. Company = "Asus",
  132. Title = "ExpertBook B1502",
  133. Price = 32999
  134. },
  135. new Product
  136. {
  137. Category = "Смарт-Часы",
  138. Company = "Apple",
  139. Title = "SE 2023",
  140. Price = 30599
  141. },
  142. new Product
  143. {
  144. Category = "Смарт-Часы",
  145. Company = "Xiaomi",
  146. Title = "Smart Band 8",
  147. Price = 3999
  148. },
  149. new Product
  150. {
  151. Category = "Смарт-Часы",
  152. Company = "Huawei",
  153. Title = "Watch GT 4",
  154. Price = 13999
  155. },
  156. };
  157. }
  158. public IEnumerable<ProductCategory> GetCategories()
  159. {
  160. return new ProductCategory[]
  161. {
  162. new ProductCategory {title = "Смартфон"},
  163. new ProductCategory {title = "Ноутбук"},
  164. new ProductCategory {title = "Смарт-Часы"},
  165. new ProductCategory {title = "Монитор"}
  166. };
  167. }
  168. public IEnumerable<ProductPrice> GetPrices()
  169. {
  170. return new ProductPrice[]
  171. {
  172. new ProductPrice{title="Все цены", priceFrom = 0, priceTo = 999999},
  173. new ProductPrice{title="До 10.000", priceFrom = 0, priceTo = 10000},
  174. new ProductPrice{title="От 10.000 до 20.000", priceFrom = 10000, priceTo = 20000},
  175. new ProductPrice{title="От 20.000 до 50.000", priceFrom = 20000, priceTo = 50000},
  176. new ProductPrice{title="Дороже 50.000", priceFrom = 50000, priceTo = 999999 }
  177. };
  178. }
  179. public IEnumerable<ProductCompany> GetCompanies()
  180. {
  181. return new ProductCompany[]
  182. {
  183. new ProductCompany{title = "Apple"},
  184. new ProductCompany{title = "Xiaomi"},
  185. new ProductCompany{title = "Huawei"},
  186. new ProductCompany{title = "POCO"},
  187. new ProductCompany{title = "Asus"},
  188. new ProductCompany{title = "Lenovo"},
  189. new ProductCompany{title = "Samsung"},
  190. new ProductCompany{title = "Acer"},
  191. new ProductCompany{title = "AOC"}
  192. };
  193. }
  194. }
  195. }