예제 #1
0
        private async Task <string> CreatePage(WebbuilderPage webbuilderPage)
        {
            //OperationStatus operationStatus = new OperationStatus();

            Guid pageid_;

            if (webbuilderPage.Mode == "A")
            {
                pageid_ = Guid.Empty;
            }
            else
            {
                pageid_ = webbuilderPage.PageID;
            }
            PortalPage portalPage = new PortalPage()
            {
                PageID      = pageid_,
                Title       = webbuilderPage.Title,
                PageName    = webbuilderPage.PageName,
                KeyWords    = webbuilderPage.KeyWords,
                Description = webbuilderPage.Description,
                IsActive    = true
            };
            List <PageRolePermission> RolePermissions = new List <PageRolePermission>();

            RolePermissions.Add(new PageRolePermission()
            {
                RoleName            = "admin",
                SelectedPageActions = "EC55BF7A-D977-4198-9BDF-12B6FA7AD4F7"
            });
            RolePermissions.Add(new PageRolePermission()
            {
                RoleName            = "Super Admin",
                SelectedPageActions = "EC55BF7A-D977-4198-9BDF-12B6FA7AD4F7"
            });
            PageController pageController = new PageController();
            string         pageid         = await pageController.AddUpdatePages(portalPage, RolePermissions, HostUrl, GetSiteID, GetUsername);

            return(pageid);
        }
예제 #2
0
        public async Task <OperationStatus> Savepage([FromBody] WebbuilderPage webbuilderPage)
        {
            OperationStatus operationStatus = new OperationStatus();
            string          pageid          = string.Empty;

            if (ModelState.IsValid)
            {
                WebBuilderController webBuilderController = new WebBuilderController(_memoryCache);
                int pageExists = await webBuilderController.CheckPage(webbuilderPage.PageName, webbuilderPage.PageID, GetSiteID);

                switch (pageExists)
                {
                case -1:
                    operationStatus.StatusCode = Cbuilder.Core.API.Enum.StatusCode.DuplicateItem;
                    operationStatus.Message    = "PageName already exists";
                    operationStatus.Result     = new string[] { "0", webbuilderPage.WebBuilderID.ToString() };
                    break
                    ;

                case -2:
                    operationStatus.StatusCode = Cbuilder.Core.API.Enum.StatusCode.Unauthorized;
                    operationStatus.Message    = "This page is system reserve page";
                    operationStatus.Result     = new string[] { "0", webbuilderPage.WebBuilderID.ToString() };
                    break;

                case 0:
                    pageid = await CreatePage(webbuilderPage);

                    Guid.TryParse(pageid, out Guid _pageid);
                    if (webbuilderPage.PageID == _pageid)
                    {
                        int rowseffected = await webBuilderController.UpdatePageName(webbuilderPage.PageName, webbuilderPage.WebBuilderID, webbuilderPage.CloneWebBuilderID, webbuilderPage.Culture);

                        operationStatus.StatusCode = Cbuilder.Core.API.Enum.StatusCode.Updated;
                        operationStatus.Result     = new string[] { webbuilderPage.PageID.ToString(), webbuilderPage.WebBuilderID.ToString() };
                    }
                    if (webbuilderPage.Mode == "A")
                    {
                        WebBuilderInfo webBuilderInfo = new WebBuilderInfo
                        {
                            CloneWebBuilderID     = webbuilderPage.CloneWebBuilderID,
                            PageComponent         = webbuilderPage.PageComponent,
                            HeaderFooterComponent = webbuilderPage.HeaderFooterComponent,
                            PageName = webbuilderPage.PageName,
                            Culture  = webbuilderPage.Culture
                        };
                        int webBuilderID = await webBuilderController.AddUpdate(webBuilderInfo, CurrentHostEnvironment.WebRootPath);

                        operationStatus.StatusCode = Cbuilder.Core.API.Enum.StatusCode.Created;
                        operationStatus.Result     = new string[] { _pageid.ToString(), webBuilderID.ToString() };
                    }
                    break;

                default:
                    break;
                }


                //SEOController seocontroller = new SEOController();
                //seocontroller.SaveSEOMetaTag(pageID, objTagValue, portalID, userName);


                //WebBuilderController webBuilderController = new WebBuilderController(_memoryCache);
                //objWebBuilderInfo.UserName = GetUsername;
                //objWebBuilderInfo.Extra = "";
            }
            return(operationStatus);
        }