コード例 #1
0
        public static string SharingGroupCategoryToString(this SharingGroupCategoryEnum type)
        {
            switch (type)
            {
            case SharingGroupCategoryEnum.UNIVERSITAIRE_DEBUTANT:
                return("Universitaire Débutant");

            case SharingGroupCategoryEnum.UNIVERSITAIRE_MAJEUR:
                return("Universitaire Majeur");

            case SharingGroupCategoryEnum.JEUNE_TRAVAILLEUR_MAJEUR:
                return("Jeune Travailleur Majeur");

            case SharingGroupCategoryEnum.JEUNE_TRAVAILLEUR:
                return("Jeune Travailleur");

            case SharingGroupCategoryEnum.JEUNE_TRAVAILLEUR_SENIOR:
                return("Jeune Travailleur Sénior");

            case SharingGroupCategoryEnum.SECOND_INTERMEDIARE:
                return("Secondaire Intermédiaire");

            case SharingGroupCategoryEnum.SECOND_JUNIOR:
                return("Secondaire Junior");

            case SharingGroupCategoryEnum.ADULTE_SINGLE:
            case SharingGroupCategoryEnum.ADULTE_MARIE:
            case SharingGroupCategoryEnum.JEUNE_MARIE:
            case SharingGroupCategoryEnum.ADULTE:
            default:
                return("Adulte");
            }
        }
コード例 #2
0
        public int GetSharingGroupIdByType(SharingGroupCategoryEnum type)
        {
            ApplicationDbContext context = ApplicationDbContext.GetDbContext();
            SharingGroup         group   = context.SharingGroups.FirstOrDefault(g => g.Type == type);

            return((group == null) ? 0 : group.Id);
        }
コード例 #3
0
        public bool GenerateSharingGroupsForMatching(bool mingle = false)
        {
            List <GroupSharingEntry> tempStack;

            this.ListAvailableSharingGroups = new Dictionary <SharingGroupCategoryEnum, List <GroupSharingEntry> >();
            if (mingle)
            {
                tempStack = ShuffleSharingGroupEntries(this.attendees.Keys.ToList(), this.sharingGroups[SharingGroupCategoryEnum.ADULTE]);
                if (tempStack == null)
                {
                    Console.WriteLine("Error in generating sharing groups per category with participants mingle");
                    return(false);
                }

                this.ListAvailableSharingGroups[SharingGroupCategoryEnum.ADULTE] = tempStack;
                return(true);
            }

            Dictionary <SharingGroupCategoryEnum, List <string> > tempDict = new Dictionary <SharingGroupCategoryEnum, List <string> >();

            foreach (KeyValuePair <string, EventAttendee> attendee in this.attendees)
            {
                //ADULTE_S | ADULTE_M | JEUNE_MARIE are mapped to ADULTE
                SharingGroupCategoryEnum sGroup = ((attendee.Value.SharingCategory == SharingGroupCategoryEnum.JEUNE_MARIE) ||
                                                   (attendee.Value.SharingCategory == SharingGroupCategoryEnum.ADULTE_MARIE) ||
                                                   ((attendee.Value.SharingCategory == SharingGroupCategoryEnum.ADULTE_SINGLE)))
                                                    ? SharingGroupCategoryEnum.ADULTE : attendee.Value.SharingCategory;

                if (!tempDict.ContainsKey(sGroup))
                {
                    tempDict[sGroup] = new List <string> {
                        attendee.Value.UserId
                    };
                }
                else
                {
                    tempDict[sGroup].Add(attendee.Value.UserId);
                }
            }

            // regroup per category
            foreach (KeyValuePair <SharingGroupCategoryEnum, List <string> > cat in tempDict)
            {
                //Number sharing groups is the number of attendee per category divided by the capacity of that category
                double nbGroup = cat.Value.Count / (double)this.sharingGroups[cat.Key];
                tempStack = ShuffleSharingGroupEntries(cat.Value, (int)Math.Ceiling(nbGroup));
                if (tempStack == null)
                {
                    Console.WriteLine("Error in generating sharing groups per category with participants not mingle");
                    return(false);
                }
                this.ListAvailableSharingGroups[cat.Key] = tempStack;
            }

            return(true);
        }