Ejemplo n.º 1
0
		private static void Update(VersionOneRestClient client)
		{
			WriteIntro("Update with an anonymous object");

			var res = client.Update("Story:1083", new
			{
				Name = "It's a test from VersionOneRestSharpClient",
				Description = "And this is a description from VersionOneRestSharpClient",
				ToDo = 9.5
			});
		}
Ejemplo n.º 2
0
		private static void Create(VersionOneRestClient client)
		{
			WriteIntro("Create:");

			var scope = "Scope:86271";

			dynamic asset = client.Create("Story", new
			{
				Name = "Testing the client.Create method at " + DateTime.Now.ToLongTimeString(),
				Description = "Just playing around...",
				Scope = scope,
				Owners = Relation("Member:20")
			});

			var oidToken = asset.OidToken;

			asset = client.Create("Issue", new
			{
				Name = "My Issue",
				Scope = scope,
				PrimaryWorkitems = Relation(oidToken)
			});
			var tok1 = asset.OidToken;
			WriteLine(tok1);

			asset = client.Create("Issue", new
			{
				Name = "My Issue 2",
				Scope = scope,
				PrimaryWorkitems = Relation(oidToken)
			});
			var tok2 = asset.OidToken;
			WriteLine(tok2);

			asset = client.Query("Story")
				.Select("Name", "Issues", "Description")
				.Where("ID", oidToken)
				.RetrieveFirst();

			WriteLine(asset);

			var storyTasks = asset._links["Issues"];

			WriteLine(storyTasks);

			//results[0].RemoveRelatedAssets("Issues", "Issue:1", "Issue:2");
			//results[0].RemoveRelatedAssets("Issues", new string[] { tok1.ToString(), tok2.ToString() });
			//results[0].RemoveRelatedAssets("Issues", new [] { tok1, tok2 });
			asset.RemoveRelatedAssets("Issues", tok1, tok2);

			storyTasks = asset._links["Issues"];
			WriteLine(storyTasks);

			asset.AddRelatedAssets("Issues", tok1);

			storyTasks = asset._links["Issues"];
			WriteLine(storyTasks);

			asset.Name = "Newbie name";
			//results[0].NewProp = "New Prop";
			asset.Description = "Just playing around...";

			var changes = asset.GetChangesDto();

			var payload = RestApiPayloadBuilder.Build(changes);

			asset = client.Update(oidToken, new
			{
				Owners = Remove("Member:20")
			});
		}