Beispiel #1
0
        public async Task VisibleDisplayByFilterDataTestVideo()
        {
            var filter = new VisibleFilter {
                VideoRestrict = true, Take = 10
            };

            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var query = new VisibleDisplayByFilter {
                Session = session, Filter = filter, CurrentUser = StandardUser
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Count().Should().Be(0);
        }
Beispiel #2
0
        public async Task VisibleDisplayByFilterDataTestImage()
        {
            var filter = new VisibleFilter {
                ImageRestrict = true, Take = 10
            };

            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var query = new VisibleDisplayByFilter {
                Session = session, Filter = filter, CurrentUser = StandardUser
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Count().Should().Be(1);
            Assert.That(query.Result.First(), Is.DeepEqualTo(VisibleData.GetFirstDisplay()));
        }
Beispiel #3
0
        public async Task VisibleDisplayByFilterDataTestAuthor()
        {
            var filter = new VisibleFilter {
                AuthorKeys = new List <string> {
                    UserData.FirstId
                }, Take = 10
            };

            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var query = new VisibleDisplayByFilter {
                Session = session, Filter = filter, CurrentUser = StandardUser
            };
            await query.Execute();

            query.Result.Should().NotBeNull();
            query.Result.Count().Should().Be(1);
        }
Beispiel #4
0
        public async Task <IActionResult> Filter([FromBody] VisibleFilter viewModel)
        {
            if (!viewModel.TenantRestrict && !CurrentUser.Right.CanSuperuser)
            {
                viewModel.TenantRestrict = true;
            }

            if (!CurrentUser.Right.CanAdmin && !CurrentUser.Right.CanSuperuser)
            {
                viewModel.AuthorKeys.Add(CurrentUser.Id);
            }

            var query = new VisibleDisplayByFilter {
                Filter = viewModel, CurrentUser = CurrentUser
            };
            await DataHandler.Execute(query);

            return(Ok(new PagedResult <IEnumerable <VisibleDisplay> >
            {
                Data = Secure(query.Result), Paging = query.Paging, Success = true
            }));
        }