public async Task <ActionResult> HelloNotify(string?name, CancellationToken cancellationToken = default) { try { var query = new HelloQuery(name); await _eventDispatcher.Publish(query, cancellationToken); return(this.StatusCode(StatusCodes.Status202Accepted)); } catch (ArgumentNullException e) { return(this.BadRequest(e.Message)); } }
public async Task <ActionResult <HelloResponse> > Hello(string?name, CancellationToken cancellationToken = default) { HttpContext?httpContext = this.HttpContext; if (httpContext != null) { _logger.LogTrace("Connection id: {ConnectionId}", httpContext.Connection.Id); } try { var query = new HelloQuery(name); HelloResponse response = await _eventDispatcher.Get(query, cancellationToken); response.ConnectionId = httpContext?.Connection.Id; return(this.Ok(response)); } catch (ArgumentNullException e) { return(this.BadRequest(e.Message)); } }