Exemplo n.º 1
0
        public override async Task Initialize()
        {
            await base.Initialize();

            var allClients = await interactorFactory.GetAllClientsInWorkspace(workspaceId).Execute();

            Clients = FilterText
                .Select(text => text ?? string.Empty)
                .Select(text =>
                {
                    var trimmedText = text.Trim();
                    var selectableViewModels = allClients
                        .Where(c => c.Name.ContainsIgnoringCase(trimmedText))
                        .Select(toSelectableViewModel);

                    var isClientFilterEmpty = string.IsNullOrEmpty(trimmedText);
                    var suggestCreation = !isClientFilterEmpty
                                          && allClients.None(c => c.Name == trimmedText)
                                          && trimmedText.LengthInBytes() <= MaxClientNameLengthInBytes;

                    if (suggestCreation)
                    {
                        var creationSelectableViewModel =
                            new SelectableClientCreationViewModel(trimmedText);
                        selectableViewModels = selectableViewModels.Prepend(creationSelectableViewModel);
                    }
                    else if (isClientFilterEmpty)
                    {
                        selectableViewModels = selectableViewModels.Prepend(noClient);
                    }

                    return selectableViewModels;
                });
        }
Exemplo n.º 2
0
        public override async Task Initialize()
        {
            await base.Initialize();

            var allClients = await interactorFactory
                             .GetAllClientsInWorkspace(workspaceId)
                             .Execute();

            Clients = FilterText
                      .Select(text => text?.Trim() ?? string.Empty)
                      .DistinctUntilChanged()
                      .Select(trimmedText => filterClientsByText(trimmedText, allClients))
                      .AsDriver(Enumerable.Empty <SelectableClientBaseViewModel>(), schedulerProvider);
        }
        public SyncFilter(string[] Lines)
        {
            InitializeComponent();

            if (!Lines.Any(x => x.Trim().Length > 0))
            {
                FilterText.Lines = DefaultLines;
            }
            else
            {
                FilterText.Lines = Lines;
            }

            FilterText.Select(FilterText.Text.Length, 0);
        }
Exemplo n.º 4
0
        public override async Task Initialize(SelectClientParameters parameter)
        {
            await base.Initialize(parameter);

            workspaceId      = parameter.WorkspaceId;
            selectedClientId = parameter.SelectedClientId;
            noClient         = new SelectableClientViewModel(0, Resources.NoClient, selectedClientId == 0);

            var allClients = await interactorFactory
                             .GetAllClientsInWorkspace(workspaceId)
                             .Execute();

            Clients = FilterText
                      .Select(text => text?.Trim() ?? string.Empty)
                      .DistinctUntilChanged()
                      .Select(trimmedText => filterClientsByText(trimmedText, allClients))
                      .AsDriver(ImmutableList <SelectableClientBaseViewModel> .Empty, schedulerProvider);
        }
        public override async Task Initialize(long? selectedCountryId)
        {
            await base.Initialize(selectedCountryId);

            var allCountries = await new GetAllCountriesInteractor().Execute();

            var selectedElement = allCountries.Find(c => c.Id == selectedCountryId);
            if (selectedElement != null)
            {
                allCountries.Remove(selectedElement);
                allCountries.Insert(0, selectedElement);
            }

            Countries = FilterText
                .Select(text => text?.Trim() ?? string.Empty)
                .DistinctUntilChanged()
                .Select(trimmedText =>
                    allCountries
                        .Where(c => c.Name.ContainsIgnoringCase(trimmedText))
                        .Select(c => new SelectableCountryViewModel(c, c.Id == selectedCountryId))
                        .ToImmutableList());
        }