Example #1
0
		void OnOrganisationUsersChanged(Organisation newOrganisation)
		{
			if (newOrganisation.UserUIDs.Any(x => x == ClientManager.CurrentUser.UID))
			{
				if (!RootItems.Any(x => x.IsOrganisation && x.Organisation.UID == newOrganisation.UID))
				{
					var organisationViewModel = new CardViewModel(newOrganisation);
					var cardFilter = new CardFilter();
					cardFilter.EmployeeFilter = new EmployeeFilter { OrganisationUIDs = new System.Collections.Generic.List<Guid> { newOrganisation.UID } };
					var cards = CardHelper.Get(cardFilter);
					if (cards == null || cards.Count() == 0)
						return;
					RootItems.Add(organisationViewModel);
					foreach (var card in cards.Where(x => x.OrganisationUID == newOrganisation.UID))
					{
						organisationViewModel.AddChild(new CardViewModel(card));
					}
					OnPropertyChanged(() => RootItems);
					OnPropertyChanged(() => RootItemsArray);
				}
			}
			else
			{
				var organisationViewModel = RootItems.FirstOrDefault(x => x.IsOrganisation && x.Organisation.UID == newOrganisation.UID);
				if (organisationViewModel != null)
				{
					RootItems.Remove(organisationViewModel);
					OnPropertyChanged(() => RootItems);
					OnPropertyChanged(() => RootItemsArray);
				}
			}
		}