Exemplo n.º 1
0
        public async Task FetchData()
        {
            IsBusy = true;

            SpeciesGroup = new ObservableCollection <SpeciesGroup>();
            var items = await _specieService.GetItems();

            var groups = await _specieGroupService.GetItems();

            var selectedArts = await _selectService.GetItems();

            var itemVMs = items.Select(i =>
            {
                var itemVM = _specieViewModelFactory();
                itemVM.SetState(i, selectedArts.Any(x => x == i.ID));
                return(itemVM);
            });

            //var itemsInGroups = itemVMs.GroupBy(g => g.GroupId);

            foreach (var g in groups.Where(gr => gr.ID != "100"))
            {
                var group = new SpeciesGroup(g.Navn, "");
                foreach (var specie in itemVMs.Where(x => x.GroupId.ToString() == g.ID))
                {
                    group.Add(specie);
                }
                SpeciesGroup.Add(group);
            }

            IsBusy = false;
        }
Exemplo n.º 2
0
        public async Task <List <PickerItem> > CreateSpeciePickerItems(string selectedId)
        {
            var species = await _specieService.GetItems();

            var ids = await _selectService.GetItems();

            var speciePickers = species.Where(s => ids.Contains(s.ID)).Select(h => new PickerItem
            {
                ID          = h.ID,
                Title       = $"{h.Navn}",
                ImageSource = Utility.GetImageSource("bird.png"),
                Selected    = selectedId == h.ID
            }).ToList();

            speciePickers = speciePickers.OrderByDescending(o => o.Selected).ToList();
            return(speciePickers);
        }
Exemplo n.º 3
0
        public async Task <List <CustomFieldViewModel> > CreateCustomFields(Logg log)
        {
            var items = await _customFieldService.GetItems();

            var selectedLoggTypes = await _selectService.GetItems();

            var itemVMs = items.Select(i =>
            {
                var itemVM = _customFieldViewModelFactory();
                itemVM.SetState(i, selectedLoggTypes.Any(x => x == i.Key));
                if (log != null)
                {
                    itemVM.Value = GetValueFromLog(i.Key, log);
                }

                return(itemVM);
            });

            return(itemVMs.ToList());
        }