private static void AddPageContent(PagesApiContext pagesApi, PageProperties page, HtmlContentWidget header, HtmlContentWidget footer, string mainHtml)
        {
            pagesApi.AddHtmlContentWidgetToPage(new AddWidgetToPageRequest() { PageId = page.Id, ContentId = header.Id, RegionIdentifier = Template.Regions.Header });
            pagesApi.AddHtmlContentWidgetToPage(new AddWidgetToPageRequest() { PageId = page.Id, ContentId = footer.Id, RegionIdentifier = Template.Regions.Footer });

            var contentRequest = new CreatePageHtmlContentRequest()
            {
                PageId = page.Id,
                RegionIdentifier = Template.Regions.Main,
                Name = "Main Content",
                Html = mainHtml,
                ContentStatus = ContentStatus.Published
            };
            pagesApi.CreatePageHtmlContent(contentRequest);
        }
        /// <summary>
        /// Creates the content of the page HTML.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns>
        /// Page content entity with created HTML content
        /// </returns>
        public PageContent CreatePageHtmlContent(CreatePageHtmlContentRequest request)
        {
            ValidateRequest(request);

            var region = GetRegion(request);

            try
            {
                UnitOfWork.BeginTransaction();

                var content = new HtmlContent
                {
                    Name = request.Name,
                    ActivationDate = request.ActivationDate ?? DateTime.Today,
                    ExpirationDate = TimeHelper.FormatEndDate(request.ExpirationDate),
                    Html = request.Html ?? string.Empty,
                    CustomCss = request.CustomCss,
                    UseCustomCss = !string.IsNullOrWhiteSpace(request.CustomCss),
                    CustomJs = request.CustomJs,
                    UseCustomJs = !string.IsNullOrWhiteSpace(request.CustomJs)
                };

                var contentService = Resolve<IContentService>();
                var contentToSave = contentService.SaveContentWithStatusUpdate(content, request.ContentStatus);

                var pageContent = SavePageContent(request.PageId, region, contentToSave);

                UnitOfWork.Commit();

                return pageContent;
            }
            catch (Exception inner)
            {
                var message = string.Format("Failed to create page HTML content.");
                Logger.Error(message, inner);
                throw new CmsApiException(message, inner);
            }
        }