public async Task <IActionResult> GetAllInvitationLinks(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(GetError(ErrorCodes.InvalidRequest, string.Format(ErrorDescriptions.ParameterIsMissing, "id"), HttpStatusCode.BadRequest));
            }

            var subject = GetSubject();

            try
            {
                var parameter = new GetAllConfirmationLinksParameter
                {
                    DocumentId = id,
                    Subject    = subject
                };
                var confirmationLinks = await _officeDocumentActions.GetAllConfirmationLinks(parameter);

                var result = confirmationLinks.ToDtos();
                foreach (var record in result)
                {
                    record.RedirectUrl = $"{_options.DocumentManagementWebsiteBaseUrl}/confirm/{record.ConfirmationCode}";
                }

                return(new OkObjectResult(result));
            }
            catch (NotAuthorizedException ex)
            {
                return(GetError(ex.Code, ex.Message, HttpStatusCode.Unauthorized));
            }
            catch (DocumentNotFoundException)
            {
                return(GetError(ErrorCodes.InvalidRequest, "the document doesn't exist", HttpStatusCode.NotFound));
            }
        }
Exemple #2
0
        public async Task <IEnumerable <OfficeDocumentConfirmationLink> > Execute(GetAllConfirmationLinksParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            _getAllConfirmationLinksValidator.Check(parameter);
            var officeDocument = await _officeDocumentRepository.Get(parameter.DocumentId);

            if (officeDocument == null)
            {
                throw new DocumentNotFoundException();
            }

            if (officeDocument.Subject != parameter.Subject)
            {
                throw new NotAuthorizedException();
            }

            return(await _officeDocumentConfirmationLinkStore.Search(new SearchOfficeDocumentConfirmationLinkParameter
            {
                DocumentIds = new[] { parameter.DocumentId }
            }));
        }
Exemple #3
0
        public void Check(GetAllConfirmationLinksParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException(nameof(parameter));
            }

            if (string.IsNullOrWhiteSpace(parameter.Subject))
            {
                throw new BaseDocumentManagementApiException(ErrorCodes.InvalidRequest, ErrorDescriptions.SubjectIsMissing);
            }
        }
 public Task <IEnumerable <OfficeDocumentConfirmationLink> > GetAllConfirmationLinks(GetAllConfirmationLinksParameter parameter)
 {
     return(_getAllConfirmationLinksAction.Execute(parameter));
 }