@@ -464,21 +464,27 @@ public OperationResult Delete(string workspaceRef, string aRef)
464464 /// <returns></returns>
465465 public CreateResult Create ( string workspaceRef , string typePath , DynamicJsonObject obj )
466466 {
467+ DynamicJsonObject response = CreateWithUri ( FormatCreateString ( workspaceRef , typePath ) , typePath , obj ) ;
468+ DynamicJsonObject createResult = response [ "CreateResult" ] ;
467469 var createResponse = new CreateResult ( ) ;
468- var data = new DynamicJsonObject ( ) ;
469- data [ typePath ] = obj ;
470- string postData = serializer . Serialize ( data ) ;
471- dynamic response =
472- serializer . Deserialize ( Service . Post ( FormatCreateString ( workspaceRef , typePath ) , postData , GetProcessedHeaders ( ) ) ) ;
473- if ( response . CreateResult . HasMember ( "Object" ) )
470+ if ( createResult . HasMember ( "Object" ) )
474471 {
475- createResponse . Reference = response . CreateResult . Object . _ref as string ;
472+ createResponse . Object = createResult [ "Object" ] ;
473+ createResponse . Reference = createResponse . Object [ "_ref" ] as string ;
476474 }
477- createResponse . Errors . AddRange ( DecodeArrayList ( response . CreateResult . Errors ) ) ;
478- createResponse . Warnings . AddRange ( DecodeArrayList ( response . CreateResult . Warnings ) ) ;
475+ createResponse . Errors . AddRange ( DecodeArrayList ( createResult [ " Errors" ] ) ) ;
476+ createResponse . Warnings . AddRange ( DecodeArrayList ( createResult [ " Warnings" ] ) ) ;
479477 return createResponse ;
480478 }
481479
480+ public DynamicJsonObject CreateWithUri ( Uri uri , string typePath , DynamicJsonObject obj )
481+ {
482+ var data = new DynamicJsonObject ( ) ;
483+ data [ typePath ] = obj ;
484+ string postData = serializer . Serialize ( data ) ;
485+ return serializer . Deserialize ( Service . Post ( uri , postData , GetProcessedHeaders ( ) ) ) ;
486+ }
487+
482488 /// <summary>
483489 /// Update the item described by the specified reference with
484490 /// the fields of the specified object
@@ -491,6 +497,24 @@ public OperationResult Update(string reference, DynamicJsonObject obj)
491497 return Update ( Ref . GetTypeFromRef ( reference ) , Ref . GetOidFromRef ( reference ) , obj ) ;
492498 }
493499
500+ public CreateResult CreateProjectTeamMembership ( String projectOid , String userOid )
501+ {
502+ Uri uri = new Uri ( String . Format ( "{0}slm/webservice/{1}/project/{2}/projectuser/{3}.js" , Service . Server . AbsoluteUri , wsapiVersion , projectOid , userOid ) ) ;
503+ DynamicJsonObject data = new DynamicJsonObject ( ) ;
504+ data [ "TeamMember" ] = true ;
505+ DynamicJsonObject response = CreateWithUri ( uri , "projectuser" , data ) ;
506+ DynamicJsonObject operationResult = response [ "OperationResult" ] ;
507+ var createResponse = new CreateResult ( ) ;
508+ if ( operationResult . HasMember ( "Object" ) )
509+ {
510+ createResponse . Object = operationResult [ "Object" ] ;
511+ createResponse . Reference = createResponse . Object [ "_ref" ] as string ;
512+ }
513+ createResponse . Errors . AddRange ( DecodeArrayList ( operationResult [ "Errors" ] ) ) ;
514+ createResponse . Warnings . AddRange ( DecodeArrayList ( operationResult [ "Warnings" ] ) ) ;
515+ return createResponse ;
516+ }
517+
494518 /// <summary>
495519 /// Update the item described by the specified type and object id with
496520 /// the fields of the specified object
0 commit comments