Ejemplo n.º 1
0
        public async Task Update_RoleRight_Test()
        {
            var role = await _roleAppService.GetRole("Administrator");

            var modules = await _moduleAppService.GetModules(new GetModulesInput());

            var module = modules.Items.FirstOrDefault(x => x.ModuleCode == "CMS.Admin.Users");

            var action = await _actionAppService.GetAction("CMS.Delete");

            Guid actionid = default(Guid);

            foreach (var am in module.ActionModules)
            {
                foreach (var r2 in role.RoleRights)
                {
                    if (am.Id == r2.ActionModuleId && am.ActionId == action.Id)
                    {
                        actionid  = r2.ActionModuleId;
                        r2.Status = false;
                    }
                }
            }

            await _roleAppService.CreateOrUpdate(role.RoleRights);

            role = await _roleAppService.GetRole("Administrator");

            role.RoleRights.FirstOrDefault(x => x.ActionModuleId == actionid).Status.ShouldBe(false);

            var str = JsonConvert.SerializeObject(role, Formatting.Indented);

            _output.WriteLine(str);
        }
Ejemplo n.º 2
0
        public async Task Create_Get_Update_Delete_Actions()
        {
            var actionTypes = new[]
            {
                "Create", "Update", "Delete", "Display", "Preview", "Search", "Export", "Test"
            };

            foreach (var item in actionTypes)
            {
                var dto = new ActionCreateDto
                {
                    ActionCode  = "CMS." + item,
                    DisplayName = item,
                    Description = item,
                    IsActive    = true
                };

                await _actionAppService.Create(dto);
            }

            var action = await _actionAppService.GetAction("CMS.Test");

            action.ShouldNotBe(null);
            action.ActionCode.ShouldBe("CMS.Test");

            action.Description = "Test, just a test!";
            await _actionAppService.Update(action);

            action = await _actionAppService.GetAction("CMS.Test");

            action.ShouldNotBe(null);
            action.Description.ShouldBe("Test, just a test!");

            await _actionAppService.Delete(new Abp.Application.Services.Dto.IdInput <Guid> {
                Id = action.Id
            });

            action = await _actionAppService.GetAction("CMS.Test");

            action.ShouldBe(null);
        }