/// <summary>
        /// Add a menu item to all nodes to show/hide unpublished children
        /// </summary>
        /// <param name="e"></param>
        /// <returns></returns>
        private void AddThinkOfTheChildrenMenuItem(MenuRenderingEventArgs e)
        {
            try
            {
                var cs = new Umbraco.Core.Services.ContentService();

                var node = cs.GetById(int.Parse(e.NodeId));
                if (node.Id != 0)
                {
                    MenuItem i = new MenuItem("thinkOfTheChildren", "Think of the children!");
                    i.AdditionalData.Add("jsAction", "totc_toggleUnpublished()");

                    e.Menu.Items.Add(i);
                }
            }
            catch (Exception ex)
            {
                log.Error("Error adding show/hide unpublished for node " + e.NodeId, ex);
            }
        }
        public ActionResult HandleAddEvent(EventViewModel model)
        {
            bool   isShipAdmin  = false;
            bool   isStateAdmin = false;
            string fname        = string.Empty;
            string lname        = string.Empty;
            string userName     = string.Empty;
            string userEmail    = System.Web.HttpContext.Current.User.Identity.Name;

            if (!ModelState.IsValid)
            {
                //return to current page
                return(CurrentUmbracoPage());
            }

            // create the RLinks list
            var relatedLinks = new List <RLinks>();

            if (System.Web.HttpContext.Current.User.IsInRole("shipcenter"))
            {
                isShipAdmin = true;
            }

            if (System.Web.HttpContext.Current.User.IsInRole("shipdirector") || System.Web.HttpContext.Current.User.IsInRole("acladmin") || System.Web.HttpContext.Current.User.IsInRole("shipadmin"))
            {
                isStateAdmin = true;
            }

            //extract the from date to date and timefrom and time to from below format
            //06/26/2016 12:00 AM - 06/26/2016 11:59 PM
            string[] dates = model.DateRange.Split('-');

            //from date
            DateTime fromDate;

            if (!DateTime.TryParse(dates[0], out fromDate))
            {
                // handle parse failure
            }

            //todate
            DateTime toDate;

            if (!DateTime.TryParse(dates[1], out toDate))
            {
                // handle parse failure
            }



            //create the content..

            //chose the correct EventNode
            //if the user role is shipCenter then pick up the intended role chosen.
            //else it is unpublished node..
            int    parentID = 0;
            string state    = "";
            string roles    = "";


            //check which role is selected and determine the parent eventsid
            if (model.Role == "1")
            {
                parentID = ConfigUtil.EventE1Id;
                roles    = "shipcenter,acladmin,partner,shipdirector,shipadmin,shipstaff,shipcounselor";
            }
            else if (model.Role == "2")
            {
                parentID = ConfigUtil.EventE2Id;
                roles    = "shipcenter,acladmin,partner,shipdirector,shipadmin,shipstaff";
            }
            else if (model.Role == "3")
            {
                parentID = ConfigUtil.EventE3Id;
                roles    = "shipcenter,acladmin,partner,shipdirector,shipadmin";
            }
            else if (model.Role == "4")
            {
                parentID = ConfigUtil.EventE4Id;
                roles    = "shipcenter,acladmin,partner,shipdirector";
            }
            else //This situation will never occur but just in case default - visible to larger audience
            {
                parentID = ConfigUtil.EventE1Id;
                roles    = "shipcenter,acladmin,partner,shipdirector,shipadmin,shipstaff,shipcounselor";
            }


            var    userService = ApplicationContext.Current.Services.MemberService;
            var    amember     = userService.GetByEmail(userEmail);
            string astate      = amember.GetValue("state").ToString();

            fname    = amember.GetValue("firstName").ToString();
            lname    = amember.GetValue("lastName").ToString();
            userName = string.Format("{0} {1}", fname, lname);



            int userID = 0;

            Umbraco.Core.Services.ContentService csv = new Umbraco.Core.Services.ContentService();


            var con = csv.CreateContent(model.Title, parentID, "Event", userID);

            //set all the values
            con.SetValue("eventtitle", model.Title);
            con.SetValue("description", model.Description);

            con.SetValue("registerlink", model.myLink1);
            con.SetValue("registercaption", model.myCaption1);

            //con.SetValue("state", state);

            con.SetValue("contributor", userName);
            con.SetValue("contributoremail", userEmail);

            //dates
            con.SetValue("eventdatetime", model.DateRange);

            con.SetValue("datetimefrom", fromDate.ToString());
            con.SetValue("datetimeto", toDate.ToString());

            con.SetValue("eventmonth", fromDate.Month.ToString());
            con.SetValue("eventyear", fromDate.Year.ToString());

            con.SetValue("intendedaudience", model.IntendedAudience);



            //populate the roles too.
            con.SetValue("roles", roles);

            csv.SaveAndPublishWithStatus(con);

            //Return the view...
            TempData["eID"]     = con.Id;
            TempData["success"] = true;
            return(CurrentUmbracoPage());
        }