Skip to content

Commit

Permalink
Update inspections after isar mission accepted
Browse files Browse the repository at this point in the history
  • Loading branch information
mrica-equinor committed Jan 23, 2025
1 parent fe8103a commit bc6dce1
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion backend/api/Services/MissionRunService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,27 @@ public async Task Update(MissionRun missionRun)
DetachTracking(context, missionRun!);
}

public async Task UpdateWithInspections(MissionRun missionRun)
{
if (missionRun.Robot is not null)
{
context.Entry(missionRun.Robot).State = EntityState.Unchanged;
}
if (missionRun.InspectionArea is not null)
{
context.Entry(missionRun.InspectionArea).State = EntityState.Unchanged;
}

var entry = context.Update(missionRun);
await ApplyDatabaseUpdate(missionRun.InspectionArea?.Installation);
_ = signalRService.SendMessageAsync(
"Mission run updated",
missionRun?.InspectionArea?.Installation,
missionRun != null ? new MissionRunResponse(missionRun) : null
);
DetachTracking(context, missionRun!);
}

public async Task<MissionRun?> Delete(string id)
{
var missionRun = await GetMissionRunsWithSubModels()
Expand Down Expand Up @@ -812,8 +833,12 @@ await ReadById(missionRunId, readOnly: true)
{
var task = missionRun.GetTaskByIsarId(isarTask.IsarTaskId);
task?.UpdateWithIsarInfo(isarTask);
var updatedTask = missionRun.Tasks.FirstOrDefault(
(task) => task.IsarTaskId == isarTask.IsarTaskId
);
updatedTask = task;
}
await Update(missionRun);
await UpdateWithInspections(missionRun);
return missionRun;
}
}
Expand Down

0 comments on commit bc6dce1

Please sign in to comment.