From 1a9e38c3d265515edb7d61621a1f5053c48186f6 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 10 May 2020 21:17:03 +0000 Subject: [PATCH] --- WorkOrder/WorkOrderCrud.cs | 107 +++++++------------------------------ util.cs | 10 +++- 2 files changed, 28 insertions(+), 89 deletions(-) diff --git a/WorkOrder/WorkOrderCrud.cs b/WorkOrder/WorkOrderCrud.cs index 1d2cef6..2693bbf 100644 --- a/WorkOrder/WorkOrderCrud.cs +++ b/WorkOrder/WorkOrderCrud.cs @@ -1,4 +1,4 @@ -using System; +using System.Linq; using Xunit; using Newtonsoft.Json.Linq; using FluentAssertions; @@ -33,6 +33,7 @@ namespace raven_integration ApiResponse a = await Util.PostAsync("workorders", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); + dynamic WorkorderToUpdate = a.ObjectResponse["data"]; long WorkOrderId = a.ObjectResponse["data"]["id"].Value(); #region CREATE first woitem @@ -76,6 +77,7 @@ namespace raven_integration a = await Util.PostAsync("workorders/items/parts", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); dynamic dPartToUpdate = a.ObjectResponse["data"]; + long PartId = (long)a.ObjectResponse["data"]["id"]; //CREATE WOITEMLABOR(S) @@ -96,6 +98,7 @@ namespace raven_integration a = await Util.PostAsync("workorders/items/labors", await Util.GetTokenAsync("manager", "l3tm3in"), d.ToString()); Util.ValidateDataReturnResponseOk(a); dynamic dLaborOne = a.ObjectResponse["data"]; + long Labor1Id = a.ObjectResponse["data"]["id"].Value(); //TWO d = new JObject(); @@ -215,101 +218,31 @@ namespace raven_integration a = await Util.PutAsync("workorders/items", await Util.GetTokenAsync("manager", "l3tm3in"), WorkOrderItemToUpdate.ToString()); Util.ValidateDataReturnResponseOk(a); - - - //todo: update labor1 - //todo: update part1 - //todo: update woitem1 - //todo: update workorder + WorkorderToUpdate.notes = "UpdatedWoNotes"; + a = await Util.PutAsync("workorders", await Util.GetTokenAsync("manager", "l3tm3in"), WorkorderToUpdate.ToString()); + Util.ValidateDataReturnResponseOk(a); - //RETRIEVE - - //Get one + //RETRIEVE WORKORDER AND VALIDATE ENTIRE a = await Util.GetAsync("workorders/" + WorkOrderId.ToString(), await Util.GetTokenAsync("manager", "l3tm3in")); Util.ValidateDataReturnResponseOk(a); - a.ObjectResponse["data"]["notes"].Value().Should().Be("WOHEADER The quick brown fox jumped over the six lazy dogs!"); + + var w = a.ObjectResponse["data"]; + ((string)w["notes"]).Should().Be("UpdatedWoNotes"); + + var woitem1 = w["items"].FirstOrDefault(z => (long)z["id"] == WorkOrderItem1Id); + ((string)woitem1["notes"]).Should().Be("UpdatedWoItemNotes"); + + ((string)woitem1["labors"].FirstOrDefault(z => (long)z["id"] == Labor1Id)["notes"]).Should().Be("UpdatedLaborNotes"); + ((string)woitem1["parts"].FirstOrDefault(z => (long)z["id"] == PartId)["notes"]).Should().Be("UpdatedPartNotes"); + + //todo: confirm entire graph exists by checking each level - /* - { - "data": { - "id": 1, - "concurrencyToken": 8722459, - "serial": 1, - "active": true, - "notes": "WOHEADER The quick brown fox jumped over the six lazy dogs!", - "wiki": "# WOHEADER test wiki", - "customFields": null, - "tags": [ - "wo-red", - "wo-green", - "wo-blue" - ], - "items": [ - { - "id": 1, - "concurrencyToken": 8722472, - "notes": "woitem The quick brown fox jumped over the six lazy dogs!", - "wiki": "# woitem test wiki", - "customFields": null, - "tags": [ - "woitem-red", - "woitem-green", - "woitem-blue" - ], - "workOrderId": 1, - "labors": [ - { - "id": 1, - "concurrencyToken": 8722486, - "notes": "woitemlabor The quick brown fox jumped over the six lazy dogs!", - "wiki": "# woitemlabor test wiki", - "customFields": null, - "tags": [ - "woitemlabor-red", - "woitemlabor-green", - "woitemlabor-blue" - ], - "workOrderItemId": 1 - }, - { - "id": 2, - "concurrencyToken": 8722493, - "notes": "woitemlabor2 The quick brown fox jumped over the six lazy dogs!", - "wiki": "# woitemlabor2 test wiki", - "customFields": null, - "tags": [ - "woitemlabor-red", - "woitemlabor-green", - "woitemlabor-blue" - ], - "workOrderItemId": 1 - } - ], - "parts": [ - { - "id": 1, - "concurrencyToken": 8722479, - "notes": "woitempart The quick brown fox jumped over the six lazy dogs!", - "wiki": "# woitempart test wiki", - "customFields": null, - "tags": [ - "woitempart-red", - "woitempart-green", - "woitempart-blue" - ], - "workOrderItemId": 1 - } - ] - } - ] - } - } - */ + // //UPDATE diff --git a/util.cs b/util.cs index cfad408..f4e508b 100644 --- a/util.cs +++ b/util.cs @@ -53,7 +53,7 @@ namespace raven_integration - // public static ConcurrentDictionary authDict = new ConcurrentDictionary();//10,32 + // public static ConcurrentDictionary authDict = new ConcurrentDictionary();//10,32 private static AutoId Auto { get; } = new AutoId(0); @@ -86,7 +86,7 @@ namespace raven_integration public async static Task GetTokenAsync(string login, string password = null) { - return await CredRepo.GetTokenAsync(login,password); + return await CredRepo.GetTokenAsync(login, password); // if (password == null) // password = login; @@ -644,5 +644,11 @@ namespace raven_integration } + + + + + //--------- + }//eoc }//eons