コード例 #1
0
        // GET: Admin/Permissions
        public ActionResult Index()
        {
            var viewModel = new PermissionsViewModel
            {
                Permissions = _permissionService.GetAll()
            };


            return(View(viewModel));
        }
コード例 #2
0
        public EditPermissionsViewModel EditPermissions(int categoryId)
        {
            using (_unitOfWorkManager.NewUnitOfWork())
            {
                var permViewModel = new EditPermissionsViewModel
                {
                    Category       = _categoryService.Get(categoryId).ToViewModel(),
                    Permissions    = _permissionService.GetAll().ToList(),
                    Groups         = _memberService.GetAll().Where(x => x.Name != AppConstants.AdminRoleName).ToList(),
                    GuestGroupName = AppConstants.GuestRoleName
                };

                var currentPermissions = _categoryPermissionService.GetAll()
                                         .Where(x => x.IsTicked && x.CategoryId == categoryId).ToList();
                var currentPermissionList = new List <string>();

                foreach (var catPerm in currentPermissions)
                {
                    currentPermissionList.Add($"{catPerm.Permission.Id}_{catPerm.CategoryId}_{catPerm.MemberGroupId}");
                }

                permViewModel.CurrentPermissions = currentPermissionList;

                //Do i need this?
                permViewModel.FullPermissionTable = _permissionService.GetFullPermissionTable(_categoryPermissionService.GetAll().ToList());
                return(permViewModel);
            }
        }
コード例 #3
0
        public void TestAddNewPermission()
        {
            string        name           = Guid.NewGuid().ToString();
            long          id             = permService.AddNewPermission(name, name);
            PermissionDTO permissionDto1 = permService.GetById(id);

            Assert.AreEqual(permissionDto1.Name, name);
            Assert.AreEqual(permissionDto1.Description, name);


            PermissionDTO permissionDto2 = permService.GetByName(name);

            Assert.AreEqual(permissionDto2.Name, name);
            Assert.AreEqual(permissionDto2.Description, name);

            var permissions = permService.GetAll();

            Assert.IsNotNull(permissions);

            string newName = Guid.NewGuid().ToString();

            permService.UpdatePermission(id, newName, newName);
            PermissionDTO permissionDto3 = permService.GetById(id);

            Assert.AreEqual(permissionDto3.Name, newName);
            Assert.AreEqual(permissionDto3.Description, newName);
            Assert.AreNotEqual(permissionDto3.Name, name);
            Assert.AreNotEqual(permissionDto3.Description, name);
        }
コード例 #4
0
 public AddSpecializationViewModel()
 {
     AvailableEquipment   = new BindableCollection <EquipmentDTO>(EquipmentService.GetAll().ToList());
     ActualEquipment      = new BindableCollection <EquipmentDTO>();
     AvailablePermissions = new BindableCollection <PermissionDTO>(PermissionService.GetAll().ToList());
     ActualPermissions    = new BindableCollection <PermissionDTO>();
     IsEdit      = false;
     ButtonLabel = "Add";
 }
コード例 #5
0
        public AddSpecializationViewModel(SpecializationDTO specialization)
        {
            AvailableEquipment = new BindableCollection <EquipmentDTO>(EquipmentService.GetAll().ToList());
            BindableCollection <EquipmentDTO> abc = new BindableCollection <EquipmentDTO>();

            foreach (var a in AvailableEquipment)
            {
                bool toDelete = false;
                foreach (var b in a.Specialization)
                {
                    if (b.Id == specialization.Id)
                    {
                        toDelete = true;
                    }
                }
                if (toDelete)
                {
                    abc.Add(a);
                }
            }
            AvailableEquipment.RemoveRange(abc);
            ActualEquipment = new BindableCollection <EquipmentDTO>(EquipmentService.GetAll().Where(x => x.Specialization.Where(y => y.Id == specialization.Id).Any()).ToList());

            AvailablePermissions = new BindableCollection <PermissionDTO>(PermissionService.GetAll().ToList());
            BindableCollection <PermissionDTO> abc1 = new BindableCollection <PermissionDTO>();

            foreach (var a in AvailablePermissions)
            {
                bool toDelete = false;
                foreach (var b in a.Specialization)
                {
                    if (b.Id == specialization.Id)
                    {
                        toDelete = true;
                    }
                }
                if (toDelete)
                {
                    abc1.Add(a);
                }
            }
            AvailablePermissions.RemoveRange(abc1);
            ActualPermissions = new BindableCollection <PermissionDTO>(PermissionService.GetAll().Where(x => x.Specialization.Where(y => y.Id == specialization.Id).Any()).ToList());
            IsEdit            = true;
            ButtonLabel       = "Edit";

            this.toEdit = specialization;
            Name        = toEdit.Name;
            Description = toEdit.Description;
            NotifyOfPropertyChange(() => Name);
            NotifyOfPropertyChange(() => Description);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: a56209/CMS
        static void Main(string[] args)
        {
            PermissionService myService = new PermissionService();
            var perms = myService.GetAll();

            foreach (var item in perms)
            {
                Console.WriteLine(item.Description);
            }
            //using (ZSZDbContext ctx = new ZSZDbContext())
            //{
            //    //ctx.Database.Delete();
            //    //ctx.Database.Create();
            //    string s = ctx.Database.Connection.ConnectionString;
            //    Console.WriteLine("创建数据库" + s);
            //}
            //Assembly[] assemblies = new Assembly[] { Assembly.Load("ZSZ.Service") };
            Console.WriteLine("ok");
            Console.ReadKey();
        }
コード例 #7
0
        private List <AdminEditRolePermissionsViewModel> GetListRolePermissions(MembershipRole Role = null)
        {
            var allPermissions = _permissionService.GetAll();
            List <Permission> SelectPermissions = null;

            if (Role != null)
            {
                SelectPermissions = _permissionService.GetPermissions(Role);
            }

            var Permissions = new List <AdminEditRolePermissionsViewModel>();

            foreach (var it in allPermissions)
            {
                var rl = new AdminEditRolePermissionsViewModel {
                    Id             = it.Id,
                    PermissionName = it.Name,
                    PermissionId   = it.PermissionId
                };

                if (SelectPermissions != null)
                {
                    foreach (var itt in SelectPermissions)
                    {
                        if (itt.Id == it.Id)
                        {
                            rl.Check = true;
                            break;
                        }
                    }
                }


                Permissions.Add(rl);
            }

            return(Permissions);
        }
コード例 #8
0
 public IActionResult GetAll([FromBody] ListParam listParam) =>
 HandleRequest(() => _permissionService.GetAll(listParam));
コード例 #9
0
ファイル: PermissionController.cs プロジェクト: rikp777/Cyto
        public IHttpActionResult GetAll()
        {
            var results = _permissionService.GetAll();

            return(Ok(results));
        }
コード例 #10
0
        public IQueryable <Permission> GetAll()
        {
            var list = _permissionService.GetAll();

            return(list.AsQueryable());
        }
コード例 #11
0
 public void Reload()
 {
     Permissions = PermissionService.GetAll();
     NotifyOfPropertyChange(() => Permissions);
 }
コード例 #12
0
 public async Task <ActionResult <ResultOutDto <IEnumerable <Permission> > > > GetPermissions()
 {
     return(Ok(ResultOutDtoBuilder.Success(await _permissionService.GetAll())));
 }