public ResModel DeleteUserQuickMenu(UserQuickMenuDto userQuickMenu) { using (var db = new ModelContext()) { var quickMenu = db.QuickMenu.FirstOrDefault(i => i.MenuId == userQuickMenu.MenuId && i.UserId == userQuickMenu.UserId); if (quickMenu == null) { return(new ResModel() { Msg = "删除失败,未找到该快捷菜单", Success = false }); } try { db.QuickMenu.Remove(quickMenu); db.SaveChanges(); } catch (Exception e) { return(new ResModel() { Msg = "删除失败", Success = false }); } return(new ResModel() { Msg = "删除成功", Success = true }); } }
public ActionResult DeleteUserQuickMenu(string menuId) { var currentUser = Session["LogUser"] as UserDto; var userQuickMenu = new UserQuickMenuDto() { UserId = currentUser.Id, MenuId = Guid.Parse(menuId) }; return(Json(_quickMenuService.DeleteUserQuickMenu(userQuickMenu))); }
public List <UserQuickMenuDto> GetUserQuickMenu(UserDto userDto) { using (var db = new ModelContext()) { var quickMenuDtos = new List <UserQuickMenuDto>(); var userQuickMenuIds = db.QuickMenu.Where(i => i.UserId == userDto.Id).Select(i => i.MenuId); var authorizedMenus = _menuRepository.GetHierarchicalMenu(userDto.Id); var topLevelMenus = authorizedMenus; foreach (var topLevelMenu in topLevelMenus) { var topQuickMenu = new UserQuickMenuDto() { Name = topLevelMenu.Name }; foreach (var secondLevelMenu in topLevelMenu.SubMenuDto) { foreach (var thirdLevelMenu in secondLevelMenu.SubMenuDto) { var userQuickMenu = new UserQuickMenuDto() { MenuId = thirdLevelMenu.Id, Name = thirdLevelMenu.Name, Url = thirdLevelMenu.Url, QuickMenuIcon = thirdLevelMenu.QuickMenuIcon }; if (userQuickMenuIds.Contains(userQuickMenu.MenuId)) { userQuickMenu.IsSelected = true; } topQuickMenu.AllThirdLevelMenu.Add(userQuickMenu); } } quickMenuDtos.Add(topQuickMenu); } return(quickMenuDtos); } }
public ResModel DeleteUserQuickMenu(UserQuickMenuDto userQuickMenu) { return(_quickMenuRepository.DeleteUserQuickMenu(userQuickMenu)); }