public ActionResult loadStuffElements(string url) { var mng = new MenuManager(); var mngMenuProfile = new MenuProfileManager(); var mngCore = new CoreManager(); var userGuid = mngCore.GetUserGuid(); var items = mng.GetMenu(); var itemsProfile = mngMenuProfile.GetProfileMenu(userGuid); return(Json(new { name = User.Identity.Name, menuItems = items.Where(x => x.parentID.GetValueOrDefault() == 0).Select(x => new { x.name, x.title, x.url, x.cssclass, isActive = !String.IsNullOrEmpty(x.pattern) && Regex.IsMatch(url, x.pattern, RegexOptions.IgnoreCase), items = items.Where(y => y.parentID.GetValueOrDefault() == x.id).Select(y => new { y.name, y.title, y.url, y.cssclass, isActive = !String.IsNullOrEmpty(y.pattern) && Regex.IsMatch(url, y.pattern, RegexOptions.IgnoreCase), items = items.Where(z => z.parentID.GetValueOrDefault() == y.id).Select(z => new { z.name, z.title, z.url, z.cssclass, isActive = !String.IsNullOrEmpty(z.pattern) && Regex.IsMatch(url, z.pattern, RegexOptions.IgnoreCase), }) }) }), menuProfileItems = itemsProfile.Select(x => new { x.id, x.name, x.href, x.cssClass }) }, JsonRequestBehavior.AllowGet)); }
public ActionResult EditProfileMenu(List <as_profileMenu> editMenu) { var mngMenuProfile = new MenuProfileManager(); var mngCore = new CoreManager(); var userGuid = mngCore.GetUserGuid(); var itemsProfile = mngMenuProfile.GetProfileMenu(userGuid); if (editMenu != null) { foreach (var item in itemsProfile) { if (!editMenu.Any(x => x.id == item.id)) { mngMenuProfile.DeleteProfileMenu(item.id); } } for (int i = 0; i < editMenu.Count; i++) { if (editMenu[i].id > 0) { mngMenuProfile.EditProfileMenu(editMenu[i].id, editMenu[i].name, editMenu[i].href, editMenu[i].cssClass); } else { editMenu[i].id = 0; editMenu[i].userGuid = userGuid; mngMenuProfile.SaveProfileMenu(editMenu[i]); } } } return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }