Exemplo n.º 1
0
        public List <UctPersonTile> SortPartners(DateTime dateTime)
        {
            var cpts = new List <UctPersonTile>();

            var possiblePartners =
                from x in PersonManager.Persons
                where x.Value.IsPartner
                orderby x.Value.LastName descending
                select x;

            List <MeetingElement> sortedMeetingElements = SortMeetingElements(dateTime);

            foreach (MeetingElement meetingElement in sortedMeetingElements)
            {
                UctPersonTile uctPartnerTile = cpts.Find(x => x.Person.Key == meetingElement.PartnerKey);
                if (uctPartnerTile == null)
                {
                    // Insert possible partners allocated in the past
                    Person partner = PersonManager.Persons[meetingElement.PartnerKey];
                    uctPartnerTile = new UctPersonTile(partner, true);
                    uctPartnerTile.AddAllocation(meetingElement);

                    cpts.Insert(0, uctPartnerTile);
                }
                else
                {
                    // Skip already inserted partners
                    uctPartnerTile.AddAllocation(meetingElement);
                }
            }

            foreach (KeyValuePair <string, Person> partner in possiblePartners)
            {
                // Skip already inserted partners
                if (cpts.Any(x => x.Person.Key == partner.Key))
                {
                    continue;
                }

                // Insert possible partners allocated never before
                var uctPartnerTile = new UctPersonTile(partner.Value, true);
                cpts.Insert(0, uctPartnerTile);
            }

            return(cpts);
        }
Exemplo n.º 2
0
        public List <UctPersonTile> SortPersons(DateTime dateTime, List <MeetingElementKey> properties)
        {
            var cpts = new List <UctPersonTile>();

            var possiblePersons =
                from x in PersonManager.Persons
                where properties.Any(y => x.Value.Properties[y])
                orderby x.Value.LastName descending
                select x;

            List <MeetingElement> sortedMeetingElements = SortMeetingElements(dateTime, properties);

            foreach (MeetingElement meetingElement in sortedMeetingElements)
            {
                UctPersonTile uctPersonTile = cpts.Find(x => x.Person.Key == meetingElement.PersonKey);
                if (uctPersonTile == null)
                {
                    // Insert possible persons allocated in the past
                    Person person = PersonManager.Persons[meetingElement.PersonKey];
                    uctPersonTile = new UctPersonTile(person, false);
                    uctPersonTile.AddAllocation(meetingElement);

                    cpts.Insert(0, uctPersonTile);
                }
                else
                {
                    // Skip already inserted persons
                    uctPersonTile.AddAllocation(meetingElement);
                }
            }

            foreach (KeyValuePair <string, Person> person in possiblePersons)
            {
                // Skip already inserted persons
                if (cpts.Any(x => x.Person.Key == person.Key))
                {
                    continue;
                }

                // Insert possible persons allocated never before
                var uctPersonTile = new UctPersonTile(person.Value, false);
                cpts.Insert(0, uctPersonTile);
            }

            return(cpts);
        }