Пример #1
0
 public Module(IModuleCore module)
 {
     Id = module.IdModule;
     Caption = module.Caption;
     Type = module.QueryType.FullName;
     UniqueName = module.UniqueName.ToString();
     UrlName = module.UrlName;
     IsConfigAllowed = module.ControllerAdmin() != null;
 }
Пример #2
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);
        }