private async Task DisplayNumberOfTimesWithOthers(MoveableIndividual theIndividual)
        {
            var otherIndividualsGroupedWith = await m_deviceDataBase.GetAllIndividualGroupingsForIndividual(theIndividual.GetIndividual());

            foreach (var groupedGroup in GroupedGroups)
            {
                foreach (var individual in groupedGroup)
                {
                    individual.NumberOfTimesGroupedWith = otherIndividualsGroupedWith.Count(ig => ig.OtherIndividualId == individual.GetIndividual().Id);
                }
            }
        }
        public GroupSelectorViewModel(IDeviceDataBase deviceDataBase, ILogService logService)
        {
            ApproveCommand = new AsyncCommand(async() =>
            {
                m_groupingStateMachine.GoToGroupsOverViewState(GroupedGroups.Where(g => g.Any()).ToList());
                try
                {
                    foreach (var groupedGroup in GroupedGroups)
                    {
                        foreach (var individual in groupedGroup)
                        {
                            var otherIndividualsInGroup = groupedGroup.Where(individualInGroup => individualInGroup.GetIndividual().Id != individual.GetIndividual().Id);
                            foreach (var otherIndividual in otherIndividualsInGroup)
                            {
                                await m_deviceDataBase.Save(new IndividualGroupings()
                                {
                                    IndividualId = individual.GetIndividual().Id, OtherIndividualId = otherIndividual.GetIndividual().Id
                                });
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    m_logService.Log(exception);
                }
            });

            GroupCommand = new Command <int>(numberOfIndividualsInGroup =>
            {
                Group(numberOfIndividualsInGroup);
            });

            ChangeSelectionCommand = new Command(() =>
            {
                m_groupingStateMachine.GoToIndividualSelectorState();
            });

            HighlightCommand = new AsyncCommand <MoveableIndividual>(async individual =>
            {
                try
                {
                    CancelMovementCommand.Execute(null);
                    m_highLightedIndividual = individual;
                    m_highLightedIndividual.IsHighligted = true;
                    var groupsToHighlight = GroupedGroups.Where(groupedIndividuals => !groupedIndividuals.Contains(individual));
                    groupsToHighlight.ForEach(g => g.IsHighlighted = true);

                    await DisplayNumberOfTimesWithOthers(individual);
                }
                catch (System.Exception exception)
                {
                    m_logService.Log(exception);
                }
            });

            CancelMovementCommand = new Command(() =>
            {
                GroupedGroups.ForEach(g => g.IsHighlighted = false);
                if (m_highLightedIndividual != null)
                {
                    m_highLightedIndividual.IsHighligted = false;
                }
                m_highLightedIndividual = null;

                GroupedGroups.ForEach(g => g.ForEach(i => i.NumberOfTimesGroupedWith = 0));
            });

            MoveIndividualCommand = new Command <GroupedIndividuals>(ig =>
            {
                var group = GroupedGroups.First(groupedIndividuals => groupedIndividuals.Contains(m_highLightedIndividual));
                group.Remove(m_highLightedIndividual);
                ig.Add(m_highLightedIndividual);
                CancelMovementCommand.Execute(null);
            });
            m_deviceDataBase = deviceDataBase;
            m_logService     = logService;
        }