Пример #1
0
        public async Task <IActionResult> Validate([FromBody] BlockChainModel blockChainModel, CancellationToken token)
        {
            blockChainModel.Verify();

            bool isValid = await _contractService.Validate(blockChainModel.ToBlockChain(), token);

            return(isValid ? Ok() : Conflict());
        }
Пример #2
0
        public async Task <IActionResult> Set(string path, [FromBody] BlockChainModel blockChainModel, CancellationToken token)
        {
            blockChainModel.Verify();
            DocumentId documentId = DocumentIdTools.FromUrlEncoding(path);

            bool isValid = await _contractService.Validate(blockChainModel.ToBlockChain(), token);

            if (!isValid)
            {
                return(Conflict());
            }

            await _contractService.Set(documentId, blockChainModel, token);

            return(Ok());
        }
Пример #3
0
        public async Task <IActionResult> Sign(string path, [FromBody] BlockChainModel blockChainModel, CancellationToken token)
        {
            blockChainModel.Verify();

            BlockChain blockChain = await _contractService.Sign(blockChainModel.ToBlockChain(), token);

            if (path == "model")
            {
                return(Ok(blockChain.ToBlockChainModel()));
            }

            DocumentId documentId = DocumentIdTools.FromUrlEncoding(path);
            await _contractService.Set(documentId, blockChain.ToBlockChainModel(), token);

            return(Ok());
        }