public ActionResult Init() { var type_finder = XCodeContainer.Resolve <ITypeFinder>(); var dr_types = type_finder.FindClassesOfType <Controller>(); var types = dr_types.Where(x => x.GetCustomAttributes(typeof(NavigateNameAttribute), true).Any()); foreach (MenuName enmu_name in Enum.GetValues(typeof(MenuName))) { var parent = new NavigateDto() { Name = enmu_name.value_name(), Url = "#", Type = MenuType.Module }; service.Add(parent); var nav_attr = types.Where(x => x.GetAttribute <NavigateNameAttribute>().ParentName == enmu_name); foreach (var type in nav_attr) { var controller_name = type.Name.Substring(0, type.Name.Length - 10); var test = type.GetMethods().Where(x => x.IsPublic && x.GetCustomAttributes(typeof(NavigateNameAttribute), true).Any()); foreach (var method_info in test) { var tetssss = method_info.GetAttribute <NavigateNameAttribute>(false); //service.add_children_nav(parent, new NavigateDto() //{ // Name = method_info.NavigateName(), // Type = tetssss.Type, // ControllerName = controller_name, // ActionName = method_info.Name, // Url = "/Adm/" + controller_name + "/" + method_info.Name //}); } } } return(RedirectToAction("Index")); }
void SetMenuType(ref NavigateDto dto) { var parentId = dto.ParentId; var parent = service.GetOne(item => item.Id == parentId); if (parentId <= 0 || parent == null) { dto.Type = MenuType.Module; } else { switch (parent.Type) { case MenuType.Module: dto.Type = MenuType.Menu; break; case MenuType.Menu: dto.Type = MenuType.ButtonType; break; } } }
/// <summary> /// 编辑Navigate /// </summary> /// <param name="dto">实体</param> /// <returns></returns> public void Update(NavigateDto dto) { var entity = Mapper.Map <NavigateDto, Navigate>(dto); repository.Update(entity); }
public ActionResult Edit(string moudleId, string menuId, string btnId, NavigateDto dto) { SetMenuType(ref dto); service.Update(dto); return(RedirectToAction("Index", RouteData.Values)); }
/// <summary> /// 添加Navigate /// </summary> /// <param name="dto">Navigate实体</param> /// <returns></returns> public void Add(NavigateDto dto) { var entity = Mapper.Map <NavigateDto, Navigate>(dto); repository.Insert(entity); }