Esempio n. 1
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);
        }