/// <summary>  Constructor for a new instance of the Delete_Verify_WebContentViewer class  </summary>
        /// <param name="RequestSpecificValues">  All the necessary, non-global data specific to the current request  </param>
        /// <param name="StaticPage"> Static page info for this request </param>
        public Delete_Verify_WebContentViewer(RequestCache RequestSpecificValues, HTML_Based_Content StaticPage)
            : base(RequestSpecificValues, StaticPage)
        {
            // Pull the web content page
            if (RequestSpecificValues.Current_Mode.WebContentID.HasValue)
            {
                webContent = SobekEngineClient.WebContent.Get_HTML_Based_Content(RequestSpecificValues.Current_Mode.WebContentID.Value, true, RequestSpecificValues.Tracer);
            }

            // This should never occur, but just a double check
            if ((webContent == null) || (!webContent.WebContentID.HasValue))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // Ensure there IS a logged on user
            RequestSpecificValues.Tracer.Add_Trace("Delete_Item_MySobekViewer.Delete_Verify_WebContentViewer", "Validate user");
            if ((RequestSpecificValues.Current_User == null) || (!RequestSpecificValues.Current_User.LoggedOn))
            {
                RequestSpecificValues.Current_Mode.Mode = Display_Mode_Enum.Aggregation;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If the user was logged on, but did not have permissions, show an error message
            canDelete = true;
            deleted   = false;
            if (!webContent.Can_Delete(RequestSpecificValues.Current_User))
            {
                errorMessage = "ERROR: You do not have permission to delete this page";
                canDelete    = false;
            }
            else if (HttpContext.Current.Request.RequestType == "POST")
            {
                string save_value = HttpContext.Current.Request.Form["admin_delete_item"];

                // Better say "DELETE", or just send back to the item
                if ((save_value != null) && (String.Compare(save_value, "DELETE", StringComparison.OrdinalIgnoreCase) == 0))
                {
                    string entered_value = HttpContext.Current.Request.Form["admin_delete_confirm"];
                    if ((entered_value == null) || (entered_value.ToUpper() != "DELETE"))
                    {
                        errorMessage = "ERROR: To verify this deletion, type DELETE into the text box and press CONFIRM";
                    }
                    else
                    {
                        string deleteReason = "Requested via web application";


                        RestResponseMessage message = SobekEngineClient.WebContent.Delete_HTML_Based_Content(webContent.WebContentID.Value, RequestSpecificValues.Current_User.Full_Name, deleteReason, RequestSpecificValues.Tracer);

                        errorMessage = message.Message;
                        if ((message.ErrorTypeEnum != ErrorRestTypeEnum.Successful) && (String.IsNullOrEmpty(errorMessage)))
                        {
                            errorMessage = "Error encountered on SobekCM engine.";
                        }
                        else
                        {
                            errorMessage = "Successfully deleted this web content page.";

                            // Clear cached data here on the client
                            CachedDataManager.WebContent.Clear_All_Web_Content_Lists();
                            CachedDataManager.WebContent.Clear_All_Web_Content_Pages();
                            CachedDataManager.WebContent.Clear_Page_Details();
                            UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear();

                            deleted = true;
                        }
                    }
                }
            }
        }
        /// <summary> Constructor for a new instance of the WebContent_Add_New_AdminViewer class </summary>
        /// <param name="RequestSpecificValues"> All the necessary, non-global data specific to the current request </param>
        /// <remarks> Postback from handling an edit or new aggregation is handled here in the constructor </remarks>
        public WebContent_Add_New_AdminViewer(RequestCache RequestSpecificValues) : base(RequestSpecificValues)
        {
            RequestSpecificValues.Tracer.Add_Trace("WebContent_Add_New_AdminViewer.Constructor", String.Empty);

            // Set some defaults
            actionMessage = String.Empty;


            // Ensure the user is the system admin or portal admin
            if ((RequestSpecificValues.Current_User == null) || ((!RequestSpecificValues.Current_User.Is_System_Admin) && (!RequestSpecificValues.Current_User.Is_Portal_Admin)))
            {
                RequestSpecificValues.Current_Mode.Mode          = Display_Mode_Enum.My_Sobek;
                RequestSpecificValues.Current_Mode.My_Sobek_Type = My_Sobek_Type_Enum.Home;
                UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
                return;
            }

            // If this is posted back, look for the reset
            if (RequestSpecificValues.Current_Mode.isPostBack)
            {
                // Pull the standard values
                NameValueCollection form = HttpContext.Current.Request.Form;

                // Get the values from the form
                if (form["admin_webcontent_title"] != null)
                {
                    title = form["admin_webcontent_title"];
                }
                if (form["admin_webcontent_desc"] != null)
                {
                    description = form["admin_webcontent_desc"];
                }
                if (form["admin_webcontent_redirect"] != null)
                {
                    redirect_url = form["admin_webcontent_redirect"];
                }
                if (form["admin_webcontent_skin"] != null)
                {
                    webSkin = form["admin_webcontent_skin"];
                }
                inheritFromParent = form["admin_webcontent_inherit"] != null;

                // Get the level values from the form
                if ((form["admin_webcontent_level1"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level1"])))
                {
                    level1 = form["admin_webcontent_level1"];
                    if ((form["admin_webcontent_level2"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level2"])))
                    {
                        level2 = form["admin_webcontent_level2"];
                        if ((form["admin_webcontent_level3"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level3"])))
                        {
                            level3 = form["admin_webcontent_level3"];
                            if ((form["admin_webcontent_level4"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level4"])))
                            {
                                level4 = form["admin_webcontent_level4"];
                                if ((form["admin_webcontent_level5"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level5"])))
                                {
                                    level5 = form["admin_webcontent_level5"];
                                    if ((form["admin_webcontent_level6"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level6"])))
                                    {
                                        level6 = form["admin_webcontent_level6"];
                                        if ((form["admin_webcontent_level7"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level7"])))
                                        {
                                            level7 = form["admin_webcontent_level7"];
                                            if ((form["admin_webcontent_level8"] != null) && (!String.IsNullOrEmpty(form["admin_webcontent_level8"])))
                                            {
                                                level8 = form["admin_webcontent_level8"];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                // Perform validation
                actionMessage = String.Empty;
                if ((String.IsNullOrEmpty(title)) || (String.IsNullOrEmpty(level1)))
                {
                    actionMessage = "Error - required fields are missing<br />";
                    if (String.IsNullOrEmpty(title))
                    {
                        actionMessage = actionMessage + " &nbsp; &nbsp; &nbsp; TITLE is a required field.<br />";
                    }
                    if (String.IsNullOrEmpty(level1))
                    {
                        actionMessage = actionMessage + " &nbsp; &nbsp; &nbsp; LEVEL1 is a required field.<br />";
                    }
                }

                string save_value = HttpContext.Current.Request.Form["admin_webcontent_save"];
                if ((!String.IsNullOrEmpty(save_value)) && (save_value == "save"))
                {
                    // Just ensure everything is emptied out
                    if (String.IsNullOrEmpty(actionMessage))
                    {
                        // Build this web content page
                        HTML_Based_Content newContent = new HTML_Based_Content
                        {
                            WebContentID = -1,
                            Level1       = level1,
                            Level2       = level2,
                            Level3       = level3,
                            Level4       = level4,
                            Level5       = level5,
                            Level6       = level6,
                            Level7       = level7,
                            Level8       = level8,
                            Title        = title,
                            Description  = description,
                            Web_Skin     = webSkin,
                            Author       = RequestSpecificValues.Current_User.Full_Name,
                            Date         = DateTime.Now.ToShortDateString()
                        };

                        if (!String.IsNullOrEmpty(description))
                        {
                            newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>" + description + "</p>";
                        }
                        else
                        {
                            newContent.Content = "<h2>" + title + "</h2>" + Environment.NewLine + "<p>New web content page text goes here.</p>";
                        }
                        newContent.ContentSource = newContent.Content;

                        // Call the engine endpoint to put this
                        RestResponseMessage msg = SobekEngineClient.WebContent.Add_HTML_Based_Content(newContent, RequestSpecificValues.Current_User.Full_Name, inheritFromParent, RequestSpecificValues.Tracer);

                        // Clear the hierarchy
                        CachedDataManager.WebContent.Clear_Hierarchy();
                        UI_ApplicationCache_Gateway.WebContent_Hierarchy_Clear();

                        // If successful, just send to it
                        if (msg != null)
                        {
                            if (msg.ErrorTypeEnum == ErrorRestTypeEnum.Successful)
                            {
                                if (String.IsNullOrEmpty(msg.URI))
                                {
                                    actionMessage = "Page added, but new URI was not returned";
                                }
                                else
                                {
                                    RequestSpecificValues.Current_Mode.Request_Completed = true;
                                    HttpContext.Current.Response.Redirect(msg.URI, false);
                                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                                    return;
                                }
                            }
                            else
                            {
                                actionMessage = "ERROR: " + msg.Message;
                            }
                        }
                        else
                        {
                            actionMessage = "ERROR: Exception deserializing the REST response message.";
                        }
                    }
                }
            }
            else
            {
                // Get any level filter information from the query string
                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l1"]))
                {
                    level1 = HttpContext.Current.Request.QueryString["l1"];

                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l2"]))
                    {
                        level2 = HttpContext.Current.Request.QueryString["l2"];

                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l3"]))
                        {
                            level3 = HttpContext.Current.Request.QueryString["l3"];

                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l4"]))
                            {
                                level4 = HttpContext.Current.Request.QueryString["l4"];

                                if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l5"]))
                                {
                                    level5 = HttpContext.Current.Request.QueryString["l5"];
                                    if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l6"]))
                                    {
                                        level6 = HttpContext.Current.Request.QueryString["l6"];
                                        if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l7"]))
                                        {
                                            level7 = HttpContext.Current.Request.QueryString["l7"];
                                            if (!String.IsNullOrEmpty(HttpContext.Current.Request.QueryString["l8"]))
                                            {
                                                level8 = HttpContext.Current.Request.QueryString["l8"];
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }