Beispiel #1
0
 public void NotifyPersonRemoval(Person removedPerson)
 {
     if (PeopleList.Contains(removedPerson, new PersonComparer()))
     {
         UpdateHelper.Instance.PeopleListRemovalHelper.Add(removedPerson);
     }
 }
Beispiel #2
0
 public void NotifyPersonModification(Person modifiedPerson)
 {
     if (PeopleList.Contains(modifiedPerson, new PersonComparer()))
     {
         UpdateHelper.Instance.PeopleListModificationHelper.Add(modifiedPerson);
     }
 }
Beispiel #3
0
 public void NotifyPersonDuplicate(Person addedPerson)
 {
     if (!PeopleList.Contains(addedPerson, new PersonComparer()))
     {
         UpdateHelper.Instance.PeopleListAdditionHelper.Add(addedPerson);
     }
 }
Beispiel #4
0
        private void PeopleUpdateTask()
        {
            if (UpdateHelper.Instance.PeopleListAdditionHelper.Count != 0)
            {
                foreach (Person p in UpdateHelper.Instance.PeopleListAdditionHelper)
                {
                    if (!PeopleList.Contains(p, new PersonComparer()))
                    {
                        PeopleList.Add(p);

                        foreach (Event e in p.ScheduledEvents)
                        {
                            Event foundEvent = EventsList.First(ev => ev.EventId.Equals(e.EventId));
                            EventsList.Remove(foundEvent);
                            foundEvent.Participants.Add(p);
                            EventsList.Add(foundEvent); //OPREZ
                        }
                    }
                }
            }

            if (UpdateHelper.Instance.PeopleListRemovalHelper.Count != 0)
            {
                foreach (Person p in UpdateHelper.Instance.PeopleListRemovalHelper)
                {
                    if (PeopleList.Contains(p, new PersonComparer()))
                    {
                        Person foundPerson = PeopleList.FirstOrDefault(pe => pe.JMBG.Equals(p.JMBG));
                        PeopleList.Remove(foundPerson);

                        foreach (Event e in p.ScheduledEvents)
                        {
                            Event foundEvent = EventsList.First(ev => ev.EventId.Equals(e.EventId));
                            EventsList.Remove(foundEvent);
                            foundEvent.Participants = new List <Person>(foundEvent.Participants.Where(per => per.JMBG != p.JMBG));
                            EventsList.Add(foundEvent);
                        }
                    }
                }
            }

            if (UpdateHelper.Instance.PeopleListModificationHelper.Count != 0)
            {
                foreach (Person p in UpdateHelper.Instance.PeopleListModificationHelper)
                {
                    if (PeopleList.Contains(p, new PersonComparer()))
                    {
                        Person foundPerson = PeopleList.FirstOrDefault(pe => pe.JMBG.Equals(p.JMBG));
                        PeopleList.Remove(foundPerson);
                        PeopleList.Add(p);

                        foreach (Event e in p.ScheduledEvents)
                        {
                            Event foundEvent = EventsList.First(ev => ev.EventId.Equals(e.EventId));
                            EventsList.Remove(foundEvent);
                            foundEvent.Participants = new List <Person>(foundEvent.Participants.Where(per => per.JMBG != p.JMBG));
                            foundEvent.Participants.Add(p);
                            EventsList.Add(foundEvent);
                        }
                    }
                }
            }

            if (++UpdateHelper.Instance.PersonCounter >= UpdateHelper.Instance.Limit - 1)
            {
                UpdateHelper.Instance.PeopleListAdditionHelper     = new List <Person>();
                UpdateHelper.Instance.PeopleListRemovalHelper      = new List <Person>();
                UpdateHelper.Instance.PeopleListModificationHelper = new List <Person>();

                UpdateHelper.Instance.PersonCounter = 0;
            }
        }