예제 #1
0
        public IEnumerable<RoleControllerActionEntity> GetAll()
        {
            List<RoleControllerActionEntity> list = new List<RoleControllerActionEntity>();
            using (var rep = DataFactory.CreateRepository<RoleRepository>())
            {
                var view = rep.Select_V_RoleControllerAction();
                foreach (var item in view)
                {
                    if (!String.IsNullOrEmpty(item.ControllerName) && !String.IsNullOrEmpty(item.ActionName))
                    {
                        var entity = new RoleControllerActionEntity(item.RoleName, item.ControllerName, item.ActionName) { Enabled = item.Enabled ?? false };
                        int typeByte = item.Type ?? 3;
                        entity.Type = (ControllerType)typeByte;

                        list.Add(entity);
                    }
                }
            }
            return list;
        }
예제 #2
0
파일: Auth.cs 프로젝트: ionixNet/TKYS
        public Result<int> SaveRoles(ParamSaveRole par)
        {
            return this.ResultSingle(() =>
            {
                var asms = AppDomain.CurrentDomain.GetAssemblies();
                var reflectedList = ControllerActionsList.Create<ReflectControllerApi, ReflectControllerMvc>(asms);

                List<RoleControllerActionEntity> list = new List<RoleControllerActionEntity>(par.Data.Count());
                foreach (var node in par.Data)
                {
                    ControllerActions ca = reflectedList[node.id.ToString()];//id değere typefullname yazılıyor.
                    foreach (var childNode in node.items)//Çünkü child note ile action lar kayıt edilmeli.
                    {
                        ActionMethodInfo ami = ca[childNode.text];

                        RoleControllerActionEntity entity = new RoleControllerActionEntity(par.RoleName, node.text, childNode.text);//role/controller/action

                        //Buda eğer controller not auharize ise işleyecek************************
                        if (ca.NotAutharize || ami.NotAutharize)//Eğer not autharize ise her türlü işlenecek.*********************************
                            entity.Enabled = true;
                        else
                            entity.Enabled = childNode.@checked;

                        entity.Type = par.Type.Cast<ControllerType>();
                        list.Add(entity);
                    }
                }

                return AuthBLL.SaveRoles(SqlRoleStorageProvider.Instance, list, AuthenticationValidator.Instance);
            });
        }