public void Update()
        {
            var query    = new SearchStateQuery();
            var searches = Mapper.Map <SearchState[]>(_queryDispatcher.Execute <SearchStateQuery, DtoSearch[]>(query).OrderBy(x => x.InstanceCreationDate));

            foreach (var balance in CustomBalances)
            {
                var input = searches.Select(x => new Selectable(x)).ToArray();
                balance.SearchesPicker.SetInput(input, input.Where(x => balance.Searches.Contains(x.Value)));
            }
        }
Beispiel #2
0
        public void SearchStateQueryHandler_SearchStateQueryEmptyDatabase_EmptyArray()
        {
            //given
            var repository = LiteDbHelper.CreateMemoryDb();
            var handler = new SearchStateQueryHandler(repository);
            var query = new SearchStateQuery();

            //when
            var result = handler.Execute(query);

            //then
            Assert.NotNull(result);
            Assert.Empty(result);
        }
Beispiel #3
0
        public void SearchStateQueryHandler_SearchStateQueryNotEmptyDatabase_Array()
        {
            //given
            var repository = LiteDbHelper.CreateMemoryDb();
            var handler = new SearchStateQueryHandler(repository);
            var query = new SearchStateQuery();
            var searchStates = new[]
            {
                new SearchState
                {
                    Name = "test 1",
                    BookDateFilter = new DateFrameSelector
                    {
                        From = DateTime.Today,
                        To = DateTime.Today.AddDays(1),
                        Type = 1
                    },
                    CategoriesFilter = new MultiPicker
                    {
                        IsChecked = true,
                        Type = 4,
                        Selected = new [] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() }
                    }
                },
                new SearchState { Name = "test 2",  }
            };
            repository.Database.GetCollection<SearchState>().InsertBulk(searchStates);

            //when
            var result = handler.Execute(query);

            //then
            result = result.OrderBy(x => x.Name).ToArray();
            Assert.Equal(searchStates.OrderBy(x => x.Name).ToArray(), result);
            Assert.Equal(searchStates[0].Name, result[0].Name);
            Assert.Equal(searchStates[0].BookDateFilter.Type, result[0].BookDateFilter.Type);
            Assert.Equal(searchStates[0].BookDateFilter.From, result[0].BookDateFilter.From);
            Assert.Equal(searchStates[0].BookDateFilter.To, result[0].BookDateFilter.To);
            Assert.Equal(searchStates[0].BookDateFilter.IsChecked, result[0].BookDateFilter.IsChecked);
            Assert.Equal(searchStates[0].CategoriesFilter.Selected, result[0].CategoriesFilter.Selected);

            Assert.Equal(searchStates[1].Name, result[1].Name);
        }
        public CustomBalanceManagerViewModel(IQueryDispatcher queryDispatcher, ICommandDispatcher commandDispatcher)
        {
            _queryDispatcher   = queryDispatcher;
            _commandDispatcher = commandDispatcher;

            AddCustomBalanceCommand = new RelayCommand(() =>
            {
                var item  = new CustomBalance(string.Empty);
                var query = new SearchStateQuery();
                item.SearchesPicker.SetInput(Mapper.Map <SearchState[]>(_queryDispatcher.Execute <SearchStateQuery, DtoSearch[]>(query)).Select(x => new Selectable(x)));
                CustomBalances.Add(item);
            });
            RemoveCustomBalanceCommand = new RelayCommand <CustomBalance>(ExecuteDeleteCommand);

            var customBalanceQuery = new CustomBalanceQuery();
            var customBalances     = _queryDispatcher.Execute <CustomBalanceQuery, DtoCustomBalance[]>(customBalanceQuery);

            CustomBalances = new TrulyObservableCollection <CustomBalance>(Mapper.Map <CustomBalance[]>(customBalances));
            CustomBalances.CollectionChanged += CustomBalancesOnCollectionChanged;
        }