/// <summary>获取当前用户拥有的角色,所对应的权限路由</summary> public async Task <List <RouterDto> > GetMenuRouterList(int userid) { var user = await _userService.GetById(userid); if (user == null) { throw new UserNotFoundException(); } if (string.IsNullOrEmpty(user.Roleid)) { return(new List <RouterDto>()); } var ids = user.Roleid.Split(',').Select(id => int.Parse(id)).ToList(); var topMenus = await _unitOfWork.MenuRepository.GetTopLevelMenusByRoleIds(ids); var dtos = new List <RouterDto>(); foreach (var topMenu in topMenus) { var subMenus = await _unitOfWork.MenuRepository.GetSubMenusByParentCode(topMenu.Code); var dto = MenuMapper.ToRouterDto(topMenu, subMenus); dtos.Add(dto); } dtos = dtos.OrderBy(it => it.Num).ToList(); return(dtos); }
public IEnumerable <MenuItemViewModel> GetByClaims(List <Tuple <string, string> > claims) { var menu = menuService.GetAll() .Where(m => claims.Any(t => t.Item1 == m.ClaimType && t.Item2 == m.ClaimValue)); return(MenuMapper.FromDomainToViewModel(menu)); }
public MenuController() { this._menuRepository = new MenuRepository(); this._menuItemRepository = new MenuItemRepository(); this._menuMapper = new MenuMapper(); this._menuItemMapper = new MenuItemMapper(); }
public Startup(IHostingEnvironment env) { var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) .AddEnvironmentVariables(); Configuration = builder.Build(); MenuMapper.Initialize(); }
/*************************/ /*** Private Functions ***/ /*************************/ /// <summary> /// CreateTreeNode() - /// </summary> /// <returns></returns> public TreeNode CreateTreeNode() { TreeNode newNode = new TreeNode(NodeName()); if (CreateAMenu()) { ContextMenuStrip contextMenu = new ContextMenuStrip(); menuMapper = new MenuMapper(contextMenu); newNode.ContextMenuStrip = contextMenu; CreateMenuOptions(); } return(newNode); }
public ActionResult AddBurger(string custName, int tableID, int bunID, int meatID, int cheeseID) { IngridientModel Bun = new IngMapper().GetIngridient(bunID); IngridientModel Meat = new IngMapper().GetIngridient(meatID); MenuModel Menu = new MenuModel { CustName = custName, TableID = tableID, Bun = Bun, Meat = Meat }; if (cheeseID != 0) { Menu.Cheese = new IngMapper().GetIngridient(cheeseID); } MenuMapper mapper = new MenuMapper(); mapper.CreateNewBurger(Menu); return(this.RedirectToAction("Index", "Burger")); }
/*******************/ /*** Constructor ***/ /*******************/ public MenuManager(MenuStrip menuStrip) { this.menuMapper = new MenuMapper(menuStrip); }