public async Task <IActionResult> AcceptOrganizationAgreement(int organizationId, int agreementId, [FromQuery] Guid?organizationAgreementGuid) { var organization = await _organizationService.GetOrganizationNoTrackingAsync(organizationId); if (organization == null) { return(NotFound(ApiResponse.Message($"Organization not found with id {organizationId}"))); } if (!organization.SigningAuthority.PermissionsRecord().EditableBy(User)) { return(Forbid()); } if (organizationAgreementGuid.HasValue) { var signedAgreement = await _organizationService.AddSignedAgreementAsync(organizationId, agreementId, organizationAgreementGuid.Value); if (signedAgreement == null) { ModelState.AddModelError(nameof(organizationAgreementGuid), "Signed Organization Agreement could not be created; network error or upload is already submitted"); return(BadRequest(ApiResponse.BadRequest(ModelState))); } } await _organizationService.AcceptOrgAgreementAsync(organizationId, agreementId); return(NoContent()); }