Created
June 9, 2023 10:14
-
-
Save AndyButland/9b21033212b4b5e5b1edde44b1422ce5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void PopulateGotoPageOnSubmit(Form form, FormDto dto) | |
{ | |
if (form.GoToPageOnSubmit == 0) | |
{ | |
return; | |
} | |
Attempt<Guid> gotToPageKeyAttempt = _entityService.GetKey(form.GoToPageOnSubmit, UmbracoObjectTypes.Document); | |
if (gotToPageKeyAttempt.Success == false) | |
{ | |
return; | |
} | |
Guid gotoPageContentId = gotToPageKeyAttempt.Result; | |
dto.GotoPageOnSubmit = gotoPageContentId; | |
IPublishedContent? gotoPageContent = GetContent(gotoPageContentId); | |
if (gotoPageContent == null) | |
{ | |
return; | |
} | |
dto.GotoPageOnSubmitRoute = _apiContentRouteBuilder.Build(gotoPageContent); | |
} | |
private IPublishedContent? GetContent(Guid id) | |
{ | |
IPublishedSnapshot publishedSnapshot = _publishedSnapshotAccessor.GetRequiredPublishedSnapshot(); | |
IPublishedContent? content = publishedSnapshot.Content?.GetById(id); | |
return content != null && content.ContentType.ItemType == PublishedItemType.Content ? content : null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment