/demos/CarBuyer/CarBuyer.Core/Services/SampleCatalogService.cs

https://github.com/SteveSandersonMS/presentation-2019-06-NDCOslo · C# · 200 lines · 198 code · 2 blank · 0 comment · 0 complexity · 3332880570ab4fbefab40453625d78d0 MD5 · raw file

  1. using System.Collections.Generic;
  2. using System.Threading.Tasks;
  3. using CarBuyer.Core.Models;
  4. namespace CarBuyer.Core.Services
  5. {
  6. public class SampleCatalogService : ICatalogService
  7. {
  8. public Task<ProductCatalog> FetchCatalogAsync()
  9. {
  10. var result = new ProductCatalog
  11. {
  12. Models = new List<CarModel>
  13. {
  14. new CarModel
  15. {
  16. Name = "6 System",
  17. NameMarkup = "<span class='code'>6</span> System",
  18. BasePrice = 26500,
  19. EstimatedDelivery = "3 - 5 weeks",
  20. EngineChoices = new List<EngineChoice>
  21. {
  22. new EngineChoice { Name = "240 kW", Description = "85mph", Price = 0 },
  23. new EngineChoice { Name = "380 kW", Description = "120mph", Price = 550 },
  24. },
  25. CustomizationGroups = new List<CustomizationGroup>
  26. {
  27. new CustomizationGroup
  28. {
  29. Name = "Exterior",
  30. Customizations = new List<CustomizationBase>
  31. {
  32. new ColorCustomization { Name = "Color" },
  33. new MultiChoiceCustomization
  34. {
  35. Name = "Wheels",
  36. Choices = new List<MultiChoiceOption>
  37. {
  38. new MultiChoiceOption { Name = "16\" alloys", Price = 0 },
  39. new MultiChoiceOption { Name = "17\" alloys", Price = 250, Notes = new[] { "Kevlar reinforced", "Additional grip" } },
  40. }
  41. },
  42. new BooleanCustomization
  43. {
  44. Name = "Panoramic sunroof",
  45. Description = "Tinted glass with UV protection",
  46. Price = 750,
  47. }
  48. }
  49. },
  50. new CustomizationGroup
  51. {
  52. Name = "Interior",
  53. Customizations = new List<CustomizationBase>
  54. {
  55. new MultiChoiceCustomization
  56. {
  57. Name = "Trim",
  58. Choices = new List<MultiChoiceOption>
  59. {
  60. new MultiChoiceOption { Name = "Standard", Price = 0, Notes = new[] { "Cloth seats", "Manual seat adjustment" } },
  61. new MultiChoiceOption { Name = "Premium", Price = 1750, Notes = new[] { "Leather seats", "Electric seat adjustment", "Digital dashboard", "Keyless entry" } },
  62. }
  63. },
  64. new MultiChoiceCustomization
  65. {
  66. Name = "Infotainment",
  67. Choices = new List<MultiChoiceOption>
  68. {
  69. new MultiChoiceOption { Name = "SE", Price = 0, Notes = new[] { "9\" screen", "4-speaker system" } },
  70. new MultiChoiceOption { Name = "SE Plus", Price = 595, Notes = new[] { "12\" touchscreen", "8-speaker system with subwoofer", "DAB radio" } },
  71. }
  72. },
  73. }
  74. },
  75. new CustomizationGroup
  76. {
  77. Name = "Safety & Convenience",
  78. Customizations = new List<CustomizationBase>
  79. {
  80. new BooleanCustomization
  81. {
  82. Name = "Emergency brake assist",
  83. Price = 325,
  84. },
  85. new BooleanCustomization
  86. {
  87. Name = "Self parking",
  88. Description = "Autonomous maneuvering into parking spaces",
  89. Price = 995,
  90. },
  91. }
  92. },
  93. }
  94. },
  95. new CarModel
  96. {
  97. Name = "8 System",
  98. NameMarkup = "<span class='code'>8</span> System",
  99. BasePrice = 41900,
  100. EstimatedDelivery = "6 - 8 weeks",
  101. EngineChoices = new List<EngineChoice>
  102. {
  103. new EngineChoice { Name = "320 kW", Description = "110mph", Price = 0 },
  104. new EngineChoice { Name = "455 kW", Description = "130mph", Price = 850 },
  105. new EngineChoice { Name = "660 kW", Description = "165mph", Price = 2300 },
  106. },
  107. CustomizationGroups = new List<CustomizationGroup>
  108. {
  109. new CustomizationGroup
  110. {
  111. Name = "Exterior",
  112. Customizations = new List<CustomizationBase>
  113. {
  114. new ColorCustomization { Name = "Color" },
  115. new MultiChoiceCustomization
  116. {
  117. Name = "Wheels",
  118. Choices = new List<MultiChoiceOption>
  119. {
  120. new MultiChoiceOption { Name = "16\" alloys", Price = 0 },
  121. new MultiChoiceOption { Name = "19\" alloys", Price = 1500, Notes = new[] { "Kevlar reinforced", "Additional grip" } },
  122. }
  123. },
  124. new BooleanCustomization
  125. {
  126. Name = "Panoramic sunroof",
  127. Description = "Tinted glass with UV protection",
  128. Price = 750,
  129. }
  130. }
  131. },
  132. new CustomizationGroup
  133. {
  134. Name = "Interior",
  135. Customizations = new List<CustomizationBase>
  136. {
  137. new MultiChoiceCustomization
  138. {
  139. Name = "Trim",
  140. Choices = new List<MultiChoiceOption>
  141. {
  142. new MultiChoiceOption { Name = "Standard", Price = 0, Notes = new[] { "Cloth seats", "Manual seat adjustment" } },
  143. new MultiChoiceOption { Name = "Premium", Price = 1750, Notes = new[] { "Leather seats", "Electric seat adjustment", "Digital dashboard", "Keyless entry" } },
  144. new MultiChoiceOption { Name = "Executive", Price = 3500, Notes = new[] { "Fine Nappa leather", "Electric seat adjustment with memory", "Windscreen-projected dashboard", "Keyless entry", "Ambient lighting" } },
  145. }
  146. },
  147. new MultiChoiceCustomization
  148. {
  149. Name = "Infotainment",
  150. Choices = new List<MultiChoiceOption>
  151. {
  152. new MultiChoiceOption { Name = "SE", Price = 0, Notes = new[] { "9\" screen", "4-speaker system" } },
  153. new MultiChoiceOption { Name = "SE Plus", Price = 595, Notes = new[] { "12\" touchscreen", "8-speaker system with subwoofer", "DAB radio" } },
  154. new MultiChoiceOption { Name = "Signature", Price = 995, Notes = new[] { "24\" touchscreen", "Bang & Olufsen 16-speaker system", "Seat-back subwoofers", "DAB + internet radio", "Wifi" } },
  155. }
  156. },
  157. }
  158. },
  159. new CustomizationGroup
  160. {
  161. Name = "Safety & Convenience",
  162. Customizations = new List<CustomizationBase>
  163. {
  164. new BooleanCustomization
  165. {
  166. Name = "Intelligent cruise control pack",
  167. Description = "Automatic lane keeping and speed control",
  168. Price = 1500,
  169. },
  170. new BooleanCustomization
  171. {
  172. Name = "Emergency brake assist",
  173. Price = 325,
  174. },
  175. new BooleanCustomization
  176. {
  177. Name = "Self parking",
  178. Description = "Autonomous maneuvering into parking spaces",
  179. Price = 995,
  180. },
  181. }
  182. },
  183. }
  184. }
  185. },
  186. LoanDownpaymentPercents = new List<decimal> { 5, 10, 25 },
  187. LoanOffers = new List<LoanOffer>
  188. {
  189. new LoanOffer { DurationMonths = 12, APR = 6.2m },
  190. new LoanOffer { DurationMonths = 24, APR = 5.8m },
  191. new LoanOffer { DurationMonths = 36, APR = 5.4m },
  192. new LoanOffer { DurationMonths = 48, APR = 4.8m },
  193. },
  194. };
  195. return Task.FromResult(result);
  196. }
  197. }
  198. }