@@ -112,6 +112,15 @@ web::json::value ModelBase::toJson( const std::shared_ptr<HttpContent>& content
112
112
}
113
113
return value;
114
114
}
115
+ web::json::value ModelBase::toJson( const std::shared_ptr<utility::datetime >& val )
116
+ {
117
+ web::json::value retVal;
118
+ if (val != nullptr)
119
+ {
120
+ retVal = toJson(*val);
121
+ }
122
+ return retVal;
123
+ }
115
124
bool ModelBase::fromString( const utility::string_t& val, bool &outVal )
116
125
{
117
126
utility::stringstream_t ss(val);
@@ -242,6 +251,19 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<HttpCo
242
251
}
243
252
return ok;
244
253
}
254
+ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr<utility::datetime >& outVal )
255
+ {
256
+ bool ok = false ;
257
+ if (outVal == nullptr)
258
+ {
259
+ outVal = std::shared_ptr< utility::datetime> (new utility::datetime());
260
+ }
261
+ if( outVal != nullptr )
262
+ {
263
+ ok = fromJson(web::json::value::parse(val), *outVal);
264
+ }
265
+ return ok;
266
+ }
245
267
bool ModelBase::fromJson( const web::json::value& val, bool & outVal )
246
268
{
247
269
outVal = ! val.is_boolean() ? false : val.as_bool();
@@ -319,6 +341,19 @@ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<HttpConte
319
341
}
320
342
return result;
321
343
}
344
+ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr<utility::datetime > &outVal )
345
+ {
346
+ bool ok = false ;
347
+ if (outVal == nullptr)
348
+ {
349
+ outVal = std::shared_ptr< utility::datetime> (new utility::datetime());
350
+ }
351
+ if( outVal != nullptr )
352
+ {
353
+ ok = fromJson(val, *outVal);
354
+ }
355
+ return ok;
356
+ }
322
357
std::shared_ptr<HttpContent > ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType )
323
358
{
324
359
std::shared_ptr< HttpContent> content( new HttpContent );
@@ -414,6 +449,18 @@ std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t&
414
449
}
415
450
return content;
416
451
}
452
+ std::shared_ptr<HttpContent > ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr<utility::datetime >& value , const utility::string_t& contentType )
453
+ {
454
+ std::shared_ptr< HttpContent> content( new HttpContent );
455
+ if (value != nullptr )
456
+ {
457
+ content-> setName ( name );
458
+ content-> setContentDisposition ( utility::conversions::to_string_t(" form-data" ) );
459
+ content-> setContentType ( contentType );
460
+ content-> setData ( std::shared_ptr< std::istream> ( new std::stringstream( utility::conversions::to_utf8string( toJson(*value).serialize() ) ) ) );
461
+ }
462
+ return content;
463
+ }
417
464
bool ModelBase::fromHttpContent(std::shared_ptr<HttpContent > val, bool & outVal )
418
465
{
419
466
utility::string_t str;
0 commit comments