Exemplo n.º 1
0
        public HttpResponseMessage DeleteLegacyItem(string nodeId, string alias, string nodeType)
        {
            //U4-2686 - alias is html encoded, make sure to decode
            alias = HttpUtility.HtmlDecode(alias);

            //In order to process this request we MUST have an HttpContext available
            var httpContextAttempt = TryGetHttpContext();
            if (httpContextAttempt.Success)
            {
                //this is a hack check based on legacy
                if (nodeType == "memberGroups")
                {
                    LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, 0, alias);
                    return Request.CreateResponse(HttpStatusCode.OK);
                }

                int id;
                if (int.TryParse(nodeId, out id))
                {
                    LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, id, alias);
                    return Request.CreateResponse(HttpStatusCode.OK);
                }

                //the way this legacy stuff used to work is that if the node id didn't parse, we would
                //pass the node id as the alias with an id of zero = sure whatevs.
                LegacyDialogHandler.Delete(httpContextAttempt.Result, Security.CurrentUser, nodeType, 0, nodeId);
                return Request.CreateResponse(HttpStatusCode.OK);
            }

            //We must have an HttpContext available for this to work.
            return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, new InvalidOperationException("No HttpContext found in the current request"));
        }
 public static void Delete(string NodeType, int NodeId, string Text)
 {
     LegacyDialogHandler.Delete(
         new HttpContextWrapper(HttpContext.Current),
         BasePage.Current.getUser(),
         NodeType, NodeId, Text);
 }
        public void Delete(string nodeId, string alias, string nodeType)
        {
            if (!AuthorizeRequest())
            {
                return;
            }

            //U4-2686 - alias is html encoded, make sure to decode
            alias = HttpUtility.HtmlDecode(alias);

            //check which parameters to pass depending on the types passed in
            int intNodeId;

            if (nodeType == "memberGroup")
            {
                LegacyDialogHandler.Delete(
                    new HttpContextWrapper(HttpContext.Current),
                    UmbracoUser,
                    nodeType, 0, nodeId);
            }
            else if (int.TryParse(nodeId, out intNodeId) && nodeType != "member") // Fix for #26965 - numeric member login gets parsed as nodeId
            {
                LegacyDialogHandler.Delete(
                    new HttpContextWrapper(HttpContext.Current),
                    UmbracoUser,
                    nodeType, intNodeId, alias);
            }
            else
            {
                LegacyDialogHandler.Delete(
                    new HttpContextWrapper(HttpContext.Current),
                    UmbracoUser,
                    nodeType, 0, nodeId);
            }
        }