private void AddPraticipantExecute(object parameter) { Participants.Add(PersonToParticipate); Person foundPerson = AvailablePeople.FirstOrDefault(p => p.JMBG.Equals(PersonToParticipate.JMBG)); AvailablePeople.Remove(foundPerson); }
private bool AddPraticipantCanExecute(object parameter) { Object[] arguments = parameter as Object[]; if (parameter == null || !(parameter is Object[] parameters) || !(parameters[0] is StatusBar)) { return(false); } else if (EventToModify.ScheduledDateTimeBeging == null || EventToModify.ScheduledDateTimeEnd == null) { ((StatusBar)arguments[0]).Visibility = Visibility.Collapsed; return(false); } foreach (Person p in PersonProxy.GetAllPeople().Where(per => per.IsAvailableForEvent(EventToModify.ScheduledDateTimeBeging, EventToModify.ScheduledDateTimeEnd))) { if (!AvailablePeople.Contains(p, new PersonComparer()) && !Participants.Contains(p, new PersonComparer())) { AvailablePeople.Add(p); } } foreach (Person p in EventToModify.Participants) { if (p.IsAvailableForEventExcludingOneSpecificEvent(EventToModify.ScheduledDateTimeBeging, EventToModify.ScheduledDateTimeEnd, EventToModify) && !AvailablePeople.Contains(p, new PersonComparer()) && !Participants.Contains(p, new PersonComparer())) { AvailablePeople.Add(p); } } ((StatusBar)arguments[0]).Visibility = Visibility.Visible; if (((ListView)arguments[1]).SelectedItem == null) { return(false); } ListView AvailablePeopleList = (ListView)arguments[1]; PersonToParticipate = AvailablePeopleList.SelectedItem as Person; if (PersonToParticipate.JMBG == null) { return(false); } return(true); }