public IActionResult UpdateCurrency([FromRoute] CurrencyId id, UpdateCurrencyCommand command) { command.Id = id; try { _commandDispatcher.Dispatch(command); var query = new GetCurrencyQuery { Id = id, }; _queryRunner.Run(query); var queryResult = query.GetResult(); var url = this.Url.Action("GetCurrency", "GetCurrency", new { id }); return(this.Ok(queryResult)); } catch (CurrencyNotFoundException ex) { return(this.NotFoundError(ex)); } catch (CodeAlreadyExistsException ex) { return(this.ConflictError(ex)); } }
public async Task <IActionResult> GetCurrencyAsync([FromRoute] int currencyId) { if (currencyId < 1) { return(Error("Invalid Currency Id")); } _logger.LogInformation("GetCurrencyAsync Called."); var query = new GetCurrencyQuery { CurrencyId = currencyId }; var list = await _messages.Dispatch(query).ConfigureAwait(false); return(Ok(list)); }
public IActionResult GetCurrency([FromQuery] CurrencyId id = null, [FromQuery] string code = null) { var query = new GetCurrencyQuery { Id = id, Code = code, }; try { _queryRunner.Run(query); var result = query.GetResult(); return(this.Ok(result)); } catch (CurrencyNotFoundException ex) { return(this.NotFoundError(ex)); } catch (ValidationException ex) { return(this.ValidationError(ex)); } }
public IActionResult CreateCurrency(CreateCurrencyCommand command) { try { _commandDispatcher.Dispatch(command); } catch (CodeAlreadyExistsException ex) { return(this.ConflictError(ex)); } var id = command.GetResult(); var query = new GetCurrencyQuery { Id = id, }; _queryRunner.Run(query); var queryResult = query.GetResult(); var url = this.Url.Action("GetCurrency", "GetCurrency", new { id }); return(this.Created(url, queryResult)); }
public async Task <IActionResult> GET_CURRENCY([FromQuery] GetCurrencyQuery query) { return(Ok(await _mediator.Send(query))); }
public async Task <IActionResult> Get([FromQuery] GetCurrencyQuery query) { return(await Execute(query)); }