public async Task <IActionResult> GetObservableSingleOperation(Guid operationId) { if (!ModelState.IsValid || !ModelState.IsValidOperationId(operationId)) { return(BadRequest(ErrorResponseFactory.Create(ModelState))); } var result = await _observableOperationRepository.GetById(operationId); if (result == null) { return(new StatusCodeResult((int)HttpStatusCode.NoContent)); } BroadcastedTransactionState MapState(BroadcastStatus status) { switch (status) { case BroadcastStatus.Completed: return(BroadcastedTransactionState.Completed); case BroadcastStatus.Failed: return(BroadcastedTransactionState.Failed); case BroadcastStatus.InProgress: return(BroadcastedTransactionState.InProgress); default: throw new InvalidCastException($"Unknown mapping from {status} "); } } return(Ok(new BroadcastedSingleTransactionResponse { Amount = MoneyConversionHelper.ToContract(result.Amount, result.AssetId), Fee = MoneyConversionHelper.ToContract(result.Fee, result.AssetId), OperationId = result.OperationId, Hash = result.TxHash, Timestamp = result.Updated, State = MapState(result.Status), Block = result.UpdatedAtBlockHeight })); }
public Task <IObservableOperation> GetById(Guid opId) { return(_observableOperationRepository.GetById(opId)); }