Exemplo n.º 1
0
        public List <ModuleModel> GetAllWithPermision(Assembly assembly, List <UserAccess> userAccess)
        {
            var modules = new SubSystemService()
                          .GetAll(Assembly.GetExecutingAssembly());

            userAccess.GroupBy(c => c.ControllerName).ToList().ForEach(c =>
            {
                var module = modules.FirstOrDefault(i => i.TitleEn == c.Key);

                if (module != null)
                {
                    module.HasPermision = true;

                    foreach (var role in c)
                    {
                        var ac = module.Actions.FirstOrDefault(p => p.TitleEn == role.ActionName);

                        if (ac != null)
                        {
                            ac.HasPermision = true;
                        }
                    }
                }
            });

            return(modules);
        }
Exemplo n.º 2
0
        public List <string> GetAllActions_DependToAction(Assembly assembly, string controllerName, string actionName)
        {
            var result = new List <string>();

            var controller = new SubSystemService()
                             .GetAll(Assembly.GetExecutingAssembly())
                             .FirstOrDefault(c => c.TitleEn.Equals(controllerName));

            if (controller != null)
            {
                result = controller
                         .Actions
                         .Where(c => !string.IsNullOrEmpty(c.DependTo) &&
                                c.DependTo.Equals(actionName))
                         .Select(c => c.TitleEn)
                         .ToList();
            }

            return(result);
        }