@@ -11,12 +11,16 @@ namespace OneNoteServiceSamplesWinUniversal.DataModel
11
11
{
12
12
public class ItemPageModel : INotifyPropertyChanged
13
13
{
14
- private string _authUserName = null ; // Logged in user name
15
- private SampleDataItem _item = null ; // Info about the current item
16
- private object _apiResponse = null ; // Response from an API request - Either a ApiBaseResponse or a List<ApiBaseResponse>
17
- private ApiBaseResponse _selectedResponse = null ; // Holds a reference to the currently selected response
14
+ private string _authUserName = null ; // Logged in user name
15
+ private SampleDataItem _item = null ; // Info about the current item
16
+ private HubContext _userData = null ;
17
+ private object _apiResponse = null ;
18
+ // Response from an API request - Either a ApiBaseResponse or a List<ApiBaseResponse>
18
19
19
- public event PropertyChangedEventHandler PropertyChanged ; // Implements INotifyPropertyChanged for notifying the binding engine when an attribute changes
20
+ private ApiBaseResponse _selectedResponse = null ; // Holds a reference to the currently selected response
21
+
22
+ public event PropertyChangedEventHandler PropertyChanged ;
23
+ // Implements INotifyPropertyChanged for notifying the binding engine when an attribute changes
20
24
21
25
/// <summary>
22
26
// NotifyPropertyChanged will fire the PropertyChanged event,
@@ -32,10 +36,7 @@ public void NotifyPropertyChanged(string propertyName)
32
36
33
37
public string AuthUserName
34
38
{
35
- get
36
- {
37
- return _authUserName ;
38
- }
39
+ get { return _authUserName ; }
39
40
40
41
set
41
42
{
@@ -45,27 +46,9 @@ public string AuthUserName
45
46
}
46
47
}
47
48
48
- public string SignInButtonTitle
49
- {
50
- get
51
- {
52
- string title = "Sign In" ;
53
-
54
- if ( Auth . IsSignedIn )
55
- {
56
- title = "Sign Out" ;
57
- }
58
-
59
- return title ;
60
- }
61
- }
62
-
63
49
public SampleDataItem Item
64
50
{
65
- get
66
- {
67
- return _item ;
68
- }
51
+ get { return _item ; }
69
52
70
53
set
71
54
{
@@ -76,6 +59,7 @@ public SampleDataItem Item
76
59
77
60
public object ApiResponse
78
61
{
62
+ get { return _apiResponse as ApiBaseResponse ; }
79
63
set
80
64
{
81
65
_apiResponse = value ;
@@ -85,14 +69,18 @@ public object ApiResponse
85
69
86
70
if ( _apiResponse != null )
87
71
{
88
- if ( _apiResponse is ApiBaseResponse )
72
+ var response = _apiResponse as ApiBaseResponse ;
73
+ if ( response != null )
89
74
{
90
- selectedResponse = _apiResponse as ApiBaseResponse ;
75
+ selectedResponse = response ;
91
76
}
92
77
else
93
78
{
94
- List < ApiBaseResponse > multipleResponses = _apiResponse as List < ApiBaseResponse > ;
95
- selectedResponse = multipleResponses [ 0 ] ;
79
+ var multipleResponses = _apiResponse as List < ApiBaseResponse > ;
80
+ if ( multipleResponses != null )
81
+ {
82
+ selectedResponse = multipleResponses [ 0 ] ;
83
+ }
96
84
}
97
85
}
98
86
@@ -105,15 +93,13 @@ public object ApiResponse
105
93
NotifyPropertyChanged ( "IsClientUrlAvailable" ) ;
106
94
NotifyPropertyChanged ( "ResponseList" ) ;
107
95
NotifyPropertyChanged ( "SelectedResponse" ) ;
96
+ NotifyPropertyChanged ( "CorrelationId" ) ;
108
97
}
109
98
}
110
99
111
100
public ApiBaseResponse SelectedResponse
112
101
{
113
- get
114
- {
115
- return _selectedResponse ;
116
- }
102
+ get { return _selectedResponse ; }
117
103
118
104
set
119
105
{
@@ -123,6 +109,17 @@ public ApiBaseResponse SelectedResponse
123
109
}
124
110
}
125
111
112
+ public HubContext UserData
113
+ {
114
+ get { return _userData ; }
115
+
116
+ set
117
+ {
118
+ _userData = value ;
119
+ NotifyPropertyChanged ( "TimeStamp" ) ;
120
+ }
121
+ }
122
+
126
123
public string StatusCode
127
124
{
128
125
get
@@ -135,7 +132,7 @@ public string StatusCode
135
132
136
133
if ( statusCode != 0 )
137
134
{
138
- statusCodeString = string . Format ( "{0}-{1}" , ( int ) statusCode , statusCode . ToString ( ) ) ;
135
+ statusCodeString = string . Format ( "{0}-{1}" , ( int ) statusCode , statusCode . ToString ( ) ) ;
139
136
}
140
137
}
141
138
@@ -149,7 +146,7 @@ public string Body
149
146
{
150
147
string body = string . Empty ;
151
148
152
- if ( _selectedResponse != null )
149
+ if ( _selectedResponse != null && _selectedResponse . Body != null )
153
150
{
154
151
body = _selectedResponse . Body ;
155
152
}
@@ -175,10 +172,7 @@ public Thickness BodyBorderThikness
175
172
176
173
public bool IsResponseAvailable
177
174
{
178
- get
179
- {
180
- return _apiResponse != null ;
181
- }
175
+ get { return _apiResponse != null ; }
182
176
}
183
177
184
178
public Visibility IsResponseListAvailable
@@ -198,10 +192,7 @@ public Visibility IsResponseListAvailable
198
192
199
193
public List < ApiBaseResponse > ResponseList
200
194
{
201
- get
202
- {
203
- return _apiResponse as List < ApiBaseResponse > ;
204
- }
195
+ get { return _apiResponse as List < ApiBaseResponse > ; }
205
196
}
206
197
207
198
public Visibility IsClientUrlAvailable
@@ -248,5 +239,23 @@ public string OneNoteWebUrl
248
239
return webUrl ;
249
240
}
250
241
}
242
+
243
+ public string CorrelationId
244
+ {
245
+ get
246
+ {
247
+ return _selectedResponse != null && ! string . IsNullOrEmpty ( _selectedResponse . CorrelationId )
248
+ ? _selectedResponse . CorrelationId
249
+ : string . Empty ;
250
+ }
251
+ }
252
+
253
+ public string TimeStamp
254
+ {
255
+ get
256
+ {
257
+ return _userData != null ? _userData . TimeStamp . ToString ( ) : string . Empty ;
258
+ }
259
+ }
251
260
}
252
261
}
0 commit comments