public async Task <IActionResult> DeleteInvitationLink(string code) { if (string.IsNullOrWhiteSpace(code)) { return(GetError(ErrorCodes.InvalidRequest, string.Format(ErrorDescriptions.ParameterIsMissing, "code"), HttpStatusCode.BadRequest)); } var subject = GetSubject(); try { var parameter = new DeleteConfirmationCodeParameter { ConfirmationCode = code, Subject = subject }; await _officeDocumentActions.DeleteConfirmationCode(parameter); return(new NoContentResult()); } catch (ConfirmationCodeNotFoundException) { return(GetError(ErrorCodes.InvalidRequest, "the confirmation code doesn't exist", HttpStatusCode.NotFound)); } catch (DocumentNotFoundException) { return(GetError(ErrorCodes.InvalidRequest, "the document doesn't exist", HttpStatusCode.NotFound)); } catch (NotAuthorizedException ex) { return(GetError(ex.Code, ex.Message, HttpStatusCode.Unauthorized)); } }
public async Task <bool> Execute(DeleteConfirmationCodeParameter parameter) { if (parameter == null) { throw new ArgumentNullException(nameof(parameter)); } _deleteConfirmationCodeParameterValidator.Check(parameter); var confirmationCode = await _officeDocumentConfirmationLinkStore.Get(parameter.ConfirmationCode); if (confirmationCode == null) { throw new ConfirmationCodeNotFoundException(); } var officeDocument = await _officeDocumentRepository.Get(confirmationCode.DocumentId); if (officeDocument == null) { throw new DocumentNotFoundException(); } if (officeDocument.Subject != parameter.Subject) { throw new NotAuthorizedException(ErrorCodes.InternalError, ErrorDescriptions.NotAuthorized); } if (!await _officeDocumentConfirmationLinkStore.Remove(parameter.ConfirmationCode)) { throw new BaseDocumentManagementApiException(ErrorCodes.InternalError, ErrorDescriptions.CannotRemoveConfirmationCode); } return(true); }
public void Check(DeleteConfirmationCodeParameter deleteConfirmationCodeParameter) { if (deleteConfirmationCodeParameter == null) { throw new ArgumentNullException(nameof(deleteConfirmationCodeParameter)); } if (string.IsNullOrWhiteSpace(deleteConfirmationCodeParameter.Subject)) { throw new BaseDocumentManagementApiException(ErrorCodes.InvalidRequest, ErrorDescriptions.SubjectIsMissing); } }
public Task <bool> DeleteConfirmationCode(DeleteConfirmationCodeParameter parameter) { return(_deleteOfficeDocumentConfirmationCodeAction.Execute(parameter)); }