Skip to content

Commit 934b82e

Browse files
committed
Add Update method. Other fixes.
1 parent 02244e3 commit 934b82e

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

AzureDevopsTracker/Services/AzureDevopsTrackerService.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ public void RemoveChangeLogItem(WorkItem workItem)
216216
/*
217217
* Still missing:
218218
* - Migration
219-
* - Update function
220219
*/
221220
public async Task Create(string jsonText, bool addWorkItemChange = true)
222221
{
@@ -230,26 +229,34 @@ public async Task Create(string jsonText, bool addWorkItemChange = true)
230229
return;
231230

232231
var customFields = ReadJsonHelper.ReadJson(workItem.Id, jsonText);
233-
if (customFields is not null && customFields.Any())
234-
workItem.AddCustomFields(customFields);
232+
if (customFields is null || !customFields.Any())
233+
return;
234+
235+
workItem.AddCustomFields(customFields);
235236
}
236237
catch
237238
{ }
238239
}
239240

240-
public Task Update(string jsonText)
241+
public async Task Update(string jsonText)
241242
{
242-
throw new NotImplementedException();
243-
244243
try
245244
{
245+
var workItemDTO = JsonConvert.DeserializeObject<UpdatedWorkItemDTO>(jsonText);
246+
await Update(workItemDTO);
246247

247-
}
248-
catch (Exception)
249-
{
248+
var workItem = await _workItemRepository.GetByWorkItemId(workItemDTO.Resource.WorkItemId);
249+
if (workItem is null)
250+
return;
251+
252+
var customFields = ReadJsonHelper.ReadJson(workItem.Id, jsonText);
253+
if (customFields is null || !customFields.Any())
254+
return;
250255

251-
throw;
256+
workItem.UpdateCustomFields(customFields);
252257
}
258+
catch
259+
{ }
253260
}
254261
#endregion
255262
}

0 commit comments

Comments
 (0)