Exemplo n.º 1
0
        public static NestedLinkCollection GetAdminMenuItems(this IModuleCore module)
        {
            var list = new NestedLinkCollection();

            var itemsInternal = (module as AdminForModules.Menu.IMenuProvider)?.GetModuleAdminMenuLinks();

            if (itemsInternal != null)
            {
                list.AddRange(itemsInternal);
            }

            try
            {
                if (module.ControllerAdmin() != null)
                {
                    var moduleAdmin = module.GetAppCore().Get <Admin.ModuleAdmin>();
                    var methods     = module.ControllerAdmin().GetMethods();
                    foreach (var method in methods)
                    {
                        var attr = method.GetCustomAttributes <AdminForModules.Menu.MenuActionAttribute>(true).FirstOrDefault();
                        if (attr != null)
                        {
                            var values = new RouteValueDictionary();
                            values.Add("controller", module.UrlName);
                            values.Add("action", string.IsNullOrEmpty(attr.Alias) ? method.Name : attr.Alias);

                            var link = new NestedLinkSimple(attr.Caption, new Uri($"/{moduleAdmin.UrlName}/mnadmin/{module.UrlName}/{(string.IsNullOrEmpty(attr.Alias) ? method.Name : attr.Alias)}", UriKind.Relative));
                            list.Add(link);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                throw ex;
            }

            return(list);
        }
Exemplo n.º 2
0
        public static NestedLinkSimple RelativeToModule(string url, string caption, IModuleCore module)
        {
            var moduleAdmin = module.GetAppCore().Get <Admin.ModuleAdmin>();

            return(new NestedLinkSimple(caption, new Uri($"/{moduleAdmin.UrlName}/mnadmin/{module.UrlName}/{url}", UriKind.Relative)));
        }
Exemplo n.º 3
0
 public static Type ControllerAdmin(this IModuleCore module)
 {
     return(module.GetAppCore().Get <ModuleControllerTypesManager>().GetModuleControllerTypes(module.QueryType).GetValueOrDefault(ControllerTypeAdmin.TypeID));
 }