public async Task <IDataAccessDataResponse> GetResponseAsync(HttpContext httpContext, XDocument xml) { XElement data = xml.Element("Params"); if (data != null) { uint[] blockIds = ((string)data.Element("p_block_array") ?? throw new DataAccessProcedureMissingData()).Split(',').Select((b) => uint.Parse(b)).ToArray(); if (blockIds.Length > 0) { DataAccessGetManyBlocksResponse response = new(); List <BlockData> blocks = await BlockManager.GetBlocksAsync(blockIds); foreach (BlockData block in blocks) { response.AddBlock(block); } if (blocks.Count != blockIds.Length) { foreach (uint blockId in blockIds) { if (!blocks.Any((b) => b.Id == blockId)) { response.AddBlock(BlockData.GetDeletedBlock(blockId)); } } } return(response); } else { return(new DataAccessGetManyBlocksResponse()); } } else { throw new DataAccessProcedureMissingData(); } }
public async Task <IDataAccessDataResponse> GetResponseAsync(HttpContext httpContext, XDocument xml) { XElement data = xml.Element("Params"); if (data != null) { uint blockId = (uint?)data.Element("p_block_id") ?? throw new DataAccessProcedureMissingData(); BlockData block = await BlockManager.GetBlockAsync(blockId); if (block != null) { return(new DataAccessGetBlock2Response(block)); } else { return(new DataAccessGetBlock2Response(BlockData.GetDeletedBlock(blockId))); } } else { throw new DataAccessProcedureMissingData(); } }