コード例 #1
0
        public async Task <PermissionTemplateDTO> Handle(EditPermissionTemplateCommand command)
        {
            PermissionTemplateProjection template = await _context.PermissionTemplateProjection.SingleOrDefaultAsync(a => a.Id == command.Input.Id);

            if (template == null)
            {
                return(new PermissionTemplateDTO());
            }

            template.Name = command.Input.Name;
            template.TemplatePermissions = command.Input.TemplatePermissions.Any()
                    ? JsonConvert.SerializeObject(command.Input.TemplatePermissions) : JsonConvert.SerializeObject(new Dictionary <Guid, string>());

            _context.PermissionTemplateProjection.Update(template);
            await _context.SaveChangesAsync();

            var returnTemplate = new PermissionTemplateDTO
            {
                Id   = template.Id,
                Name = template.Name,
                TemplatePermissions = command.Input.TemplatePermissions,
            };

            return(returnTemplate);
        }
コード例 #2
0
        public async void setup_context_to_return_one_item(PermissionTemplateProjection proj)
        {
            var list = new List <PermissionTemplateProjection>
            {
                proj
            };

            ContextMock.Setup(a => a.PermissionTemplateProjection)
            .Returns(MockDbSetFactory.MockDbSet(list).Object);

            ContextMock.Setup(a => a.PermissionTemplateProjection.Remove(proj))
            .Callback <PermissionTemplateProjection>((a) =>
            {
                list.Remove(a);
                ContextRemoveWasCalled = true;
            })
            .Returns((EntityEntry <PermissionTemplateProjection>)null);

            ContextMock.Setup(a => a.SaveChangesAsync(It.IsAny <CancellationToken>()))
            .Callback(() =>
            {
                ContextSaveWasCalled = true;
            })
            .ReturnsAsync(await Task.FromResult(0));
        }
コード例 #3
0
        public async Task <string> Handle(DeletePermissionTemplateCommand command)
        {
            PermissionTemplateProjection template = await _context.PermissionTemplateProjection.SingleOrDefaultAsync(a => a.Id == command.Input.Id);

            if (template != null)
            {
                _context.PermissionTemplateProjection.Remove(template);
                await _context.SaveChangesAsync();

                return($"Template \"{template.Name}\" was successfully Removed.");
            }

            return($"Template was not successfully Removed.");
        }
コード例 #4
0
 public GenericEventPublisher(
     UserDetailProjection userDetailProjection,
     PermissionDetailProjection permissionDetailProjection,
     PendingRequestsProjection pendingRequestsProjection,
     SystemDropdownProjection systemDropdownProjection,
     UserManagementProjection userManagementProjection,
     SystemActivityProjection systemActivityProjection,
     ApproverActivityProjection approverActivityProjection,
     PermissionTemplateProjection permissionTemplateProjection,
     DashboardProjection dashboardProjection,
     UserHistoryProjection userHistoryProjection
     )
 {
     _userDetailProjection         = userDetailProjection;
     _permissionDetailProjection   = permissionDetailProjection;
     _pendingRequestsProjection    = pendingRequestsProjection;
     _userManagementProjection     = userManagementProjection;
     _systemDropdownProjection     = systemDropdownProjection;
     _approverActivityProjection   = approverActivityProjection;
     _systemActivityProjection     = systemActivityProjection;
     _permissionTemplateProjection = permissionTemplateProjection;
     _dashBoardProjection          = dashboardProjection;
     _userHistoryProjection        = userHistoryProjection;
 }
コード例 #5
0
        public PermissionTemplateProjection SetupTestPermissionTemplate()
        {
            var createPermisisonDTO = new CreateNewPermissionDTO
            {
                Name        = "testPermisison",
                Description = "testDescription",
                IsActive    = true,
                Image       = "testUrl"
            };

            var permAgg = PermissionAggregate.CreateNewPermission(createPermisisonDTO);

            var permissionTemplate = new PermissionTemplateProjection
            {
                Id   = new Guid(),
                Name = "testName",
                TemplatePermissions = JsonConvert.SerializeObject(new Dictionary <Guid, string>
                {
                    { permAgg.Id, permAgg.Name }
                })
            };

            return(permissionTemplate);
        }
コード例 #6
0
        public async Task <PermissionTemplateDTO> Handle(CreatePermissionTemplateCommand command)
        {
            PermissionTemplateProjection template = new PermissionTemplateProjection
            {
                Id   = Guid.NewGuid(),
                Name = command.Input.Name,
                TemplatePermissions = command.Input.TemplatePermissions.Any() ?
                                      JsonConvert.SerializeObject(command.Input.TemplatePermissions) :
                                      JsonConvert.SerializeObject(new Dictionary <Guid, string>()),
            };

            await _context.PermissionTemplateProjection.AddAsync(template);

            await _context.SaveChangesAsync();

            var returnTemplate = new PermissionTemplateDTO
            {
                Id   = template.Id,
                Name = template.Name,
                TemplatePermissions = command.Input.TemplatePermissions,
            };

            return(returnTemplate);
        }