20
|
1 using GalaSoft.MvvmLight;
|
|
2 using Stocks.Common.Models;
|
|
3
|
|
4 namespace Stocks.UI
|
|
5 {
|
|
6 public class DisplayStockPrice : ObservableObject
|
|
7 {
|
|
8 public static DisplayStockPrice Create(Price price)
|
|
9 {
|
|
10 return new DisplayStockPrice()
|
|
11 {
|
|
12 Symbol = price.Symbol,
|
|
13 CurrentPrice = price.CurrentPrice,
|
|
14 PreviousPrice = price.PreviousPrice
|
|
15 };
|
|
16 }
|
|
17
|
|
18 public void Update(Price price)
|
|
19 {
|
|
20 Symbol = price.Symbol;
|
|
21 CurrentPrice = price.CurrentPrice;
|
|
22 PreviousPrice = price.PreviousPrice;
|
|
23 }
|
|
24
|
|
25 public const string SymbolPropertyName = "Symbol";
|
|
26 private string _symbol;
|
|
27 public string Symbol
|
|
28 {
|
|
29 get { return _symbol; }
|
|
30 private set
|
|
31 {
|
|
32 if (_symbol == value) return;
|
|
33 _symbol = value;
|
|
34 RaisePropertyChanged(SymbolPropertyName);
|
|
35 }
|
|
36 }
|
|
37
|
|
38 public const string CompanyNamePropertyName = "CompanyName";
|
|
39 private string _companyName;
|
|
40 public string CompanyName
|
|
41 {
|
|
42 get { return _companyName; }
|
|
43 private set
|
|
44 {
|
|
45 if (_companyName == value) return;
|
|
46 _companyName = value;
|
|
47 RaisePropertyChanged(CompanyNamePropertyName);
|
|
48 }
|
|
49 }
|
|
50
|
|
51 public const string CurrentPricePropertyName = "CurrentPrice";
|
|
52 private decimal _currentPrice = 0;
|
|
53 public decimal CurrentPrice
|
|
54 {
|
|
55 get { return _currentPrice; }
|
|
56 private set
|
|
57 {
|
|
58 if (_currentPrice == value) return;
|
|
59 _currentPrice = value;
|
|
60 RaisePropertyChanged(CurrentPricePropertyName);
|
|
61 }
|
|
62 }
|
|
63
|
|
64 public const string PreviousPricePropertyName = "PreviousPrice";
|
|
65 private decimal _previousPrice = 0;
|
|
66 public decimal PreviousPrice
|
|
67 {
|
|
68 get { return _previousPrice; }
|
|
69 private set
|
|
70 {
|
|
71 if (_previousPrice == value) return;
|
|
72 _previousPrice = value;
|
|
73 RaisePropertyChanged(PreviousPricePropertyName);
|
|
74 }
|
|
75 }
|
|
76
|
|
77 public const string DeltaPropertyName = "Delta";
|
|
78 private decimal _delta = 0;
|
|
79 public decimal Delta
|
|
80 {
|
|
81 get { return _delta; }
|
|
82 private set
|
|
83 {
|
|
84 if (_delta == value) return;
|
|
85 _delta = value;
|
|
86 RaisePropertyChanged(DeltaPropertyName);
|
|
87 }
|
|
88 }
|
|
89 }
|
|
90 }
|