예제 #1
0
        public async Task <ActionResult <Document> > CreateDocumentAsync([FromBody] DocumentInput documentDetails)
        {
            ApiArgumentNullException.ThrowIfNull(documentDetails?.DocumentType);
            ApiArgumentNullException.ThrowIfNull(documentDetails?.Signers);

            Document document = await documentService.CreateDocumentAsync(documentDetails, HttpContext.User.GetUserId()).ConfigureAwait(false);

            return(new OkObjectResult(document));
        }
예제 #2
0
        public async Task <ActionResult <Document> > GetDocumentAsync([FromRoute] Guid documentId)
        {
            ApiArgumentNullException.ThrowIfNull(documentId);
            if (documentId == default)
            {
                throw new ApiArgumentException($"'{nameof(documentId)}' must be a non default Guid.", nameof(documentId));
            }
            var document = await this.documentService.GetDocumentAsync(documentId);

            await authorizationService.AuthorizeAsync(User, document, AuthZPolicy.GetDocumentPolicy);

            return(new OkObjectResult(document));
        }
예제 #3
0
        public async Task <ActionResult <Signature> > SignDocumentAsync([FromRoute] string documentId, [FromBody] Signature signature)
        {
            ApiArgumentNullException.ThrowIfNull(documentId);
            ApiArgumentNullException.ThrowIfNull(signature);

            Guid parsedDocumentId;

            if (!Guid.TryParse(documentId, out parsedDocumentId) ||
                parsedDocumentId == default)
            {
                throw new ApiArgumentException($"'{nameof(documentId)}' must be a non default Guid.", nameof(documentId));
            }

            await authorizationService.AuthorizeAsync(User, signature, AuthZPolicy.SignDocumentPolicy);

            Signature signatureResult = await documentService.SignDocumentAsync(parsedDocumentId, signature).ConfigureAwait(false);

            return(new OkObjectResult(signatureResult));
        }