Skip to content

Instantly share code, notes, and snippets.

@AndyButland
Created June 9, 2023 10:14
Show Gist options
  • Save AndyButland/9b21033212b4b5e5b1edde44b1422ce5 to your computer and use it in GitHub Desktop.
Save AndyButland/9b21033212b4b5e5b1edde44b1422ce5 to your computer and use it in GitHub Desktop.
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