public async Task <ActionResult <Trace> > Create(Trace trace) { var run = await _context.Runs.Include(r => r.Box.Grants).SingleOrDefaultAsync(r => r.Id == trace.RunId); if (run == null) { return(NotFound()); } if (!run.Box.HasWriteAccess(User.GetIdentifier())) { return(Forbid()); } if (!trace.BelongsTo(run)) { return(Conflict(run)); } trace.Run = run; _context.Traces.Add(trace); await _context.SaveChangesAsync(); await _hubContext.Clients.Group(run.Id.ToString()).SendAsync("Trace", trace); return(trace); }