public ActionResult Create(MenuSiteModel Model)
        {
            if (String.IsNullOrEmpty(Model.Name))
            {
                return(Create().WithError("Please provide a valid name!"));
            }

            MenuSite newEntry = new MenuSite();

            newEntry.MenuName = Model.Name;

            using (CityInfoDBEntities dc = new CityInfoDBEntities())
            {
                var MenuSiteModelId = dc.MenuSites.FirstOrDefault(i => i.MenuName == Model.SelectedParent);
                if (MenuSiteModelId != null)
                {
                    newEntry.ParentId = MenuSiteModelId.MenuId;
                }
                else
                {
                    newEntry.ParentId = 0;
                }


                dc.MenuSites.Add(newEntry);
                dc.SaveChanges();
            }

            return(RedirectToAction <HomeController>(c => c.Index()).WithSuccess("Item Created!"));
        }
        public void DeleteBranch(CityInfoDBEntities dc, MenuSite branch)
        {
            var childList = dc.MenuSites.Where(a => a.ParentId == branch.MenuId).ToList();

            if (childList.Count != 0)
            {
                foreach (var child in childList)
                {
                    DeleteBranch(dc, child);
                }
            }
            dc.MenuSites.Remove(branch);
        }