private async Task <Domain.Models.Plan> CreatePlan(Domain.Models.Run run) { var plan = new Domain.Models.Plan { RunId = run.Id, Status = Domain.Models.PlanStatus.Planning }; run.Plan = plan; run.Status = Domain.Models.RunStatus.Planning; await _db.AddAsync(plan); await _db.SaveChangesAsync(); _output = _outputService.GetOrAddOutput(plan.Id); await _mediator.Publish(new RunUpdated(run.Id)); return(plan); }