public Result <object> Search(string hash) { using (var uow = NewUnitOfWork()) { if (NewRepository <Address>(uow).Exists(a => a.BlockchainAddress == hash)) { return(ProcessSearchResult(_addressInfoService.GetAddressInfo(hash))); } else if (NewRepository <Account>(uow).Exists(a => a.Hash == hash)) { return(ProcessSearchResult(GetAccountInfo(hash))); } else if (NewRepository <Asset>(uow).Exists(a => a.Hash == hash)) { return(ProcessSearchResult(GetAssetInfo(hash))); } else if (NewRepository <Transaction>(uow).Exists(t => t.Hash == hash)) { return(ProcessSearchResult(_txInfoService.GetTxInfo(hash))); } else if (NewRepository <Equivocation>(uow).Exists(e => e.EquivocationProofHash == hash)) { return(ProcessSearchResult(GetEquivocationInfo(hash))); } else { if (long.TryParse(hash, out long number)) { if (NewRepository <Block>(uow).Exists(a => a.BlockNumber == number)) { return(ProcessSearchResult(_blockInfoService.GetBlockInfo(number))); } } } return(Result.Failure <object>("Not found.")); } }
public IActionResult GetBlockInfo(long blockNumber) { return(ApiResult(_blockInfoService.GetBlockInfo(blockNumber), r => NotFound(r))); }