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); }
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)); }
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."); }
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; }
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); }
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); }