Ejemplo n.º 1
0
        public int GetIdByProperties(string name, DormitoryTypeEnum type, DormitoryCategoryEnum cat)
        {
            ApplicationDbContext context = ApplicationDbContext.GetDbContext();
            Dormitory            dorm    = context.Dorms.FirstOrDefault(d => d.Name.Equals(name) &&
                                                                        d.DormType == type && d.DormCategory == cat);

            if (dorm != null)
            {
                return(dorm.Id);
            }

            return(0);
        }
Ejemplo n.º 2
0
        protected DormEntry GetDormEntry(DormitoryTypeEnum dormType, DormitoryCategoryEnum dormCat)
        {
            if (this.ListAvailableDorms.IsNullOrEmpty() ||
                !this.ListAvailableDorms.ContainsKey(dormType) ||
                this.ListAvailableDorms[dormType].IsNullOrEmpty() ||
                !this.ListAvailableDorms[dormType].ContainsKey(dormCat) ||
                this.ListAvailableDorms[dormType][dormCat].IsNullOrEmpty()
                )
            {
                Console.WriteLine("GetDormEntry(): No bed available!");
                return(null);
            }

            return(this.ListAvailableDorms[dormType][dormCat].Pop());
        }
Ejemplo n.º 3
0
        public static string DormitoryTypeToString(this DormitoryTypeEnum type)
        {
            string ret = "Dortoir ";

            switch (type)
            {
            case DormitoryTypeEnum.MEN:
                return(ret + "Homme");

            case DormitoryTypeEnum.WOMEN:
                return(ret + "Femme");

            case DormitoryTypeEnum.NONE:
                return(ret + "Commun");

            default:
                return("Inconnu");
            }
        }
Ejemplo n.º 4
0
        public void GenerateAllBadges()
        {
            EnsureLoaded();
            if (!this.GenerateSeatsForMatching(this.CurrentEvent.MingleAttendees) ||
                !this.GenerateBedsForMatching(this.CurrentEvent.MingleAttendees) ||
                !this.GenerateTablesForMatching(this.CurrentEvent.MingleAttendees) ||
                !this.GenerateSharingGroupsForMatching(this.CurrentEvent.MingleAttendees))
            {
                return;
            }

            // Check that we have enough places (Seats, beds, tables) available for the matching
            int nbrAttendees = this.attendees.Count;
            int nbrSections  = ListAvailableSections.Count();
            int nbrDorms     = ListAvailableDorms.Count();
            int nbrTables    = ListAvailableTables.Count();

            if (nbrSections < nbrAttendees ||
                nbrDorms < nbrAttendees ||
                nbrTables < nbrAttendees)
            {
                Console.WriteLine(String.Format("Not enought resources available for registered attendees! " +
                                                "Sections: {0}, Dorms: {1}, Tables: {2}", nbrSections, nbrDorms, nbrTables));
                return;
            }

            int nbAssignment = 0;

            foreach (KeyValuePair <SharingGroupCategoryEnum, List <GroupSharingEntry> > cat in this.ListAvailableSharingGroups)
            {
                foreach (GroupSharingEntry gshare in cat.Value)
                {
                    string        attendeeKey = gshare.UserId;
                    EventAttendee attendee    = this.attendees[attendeeKey];
                    HallEntry     aSeat       = GetHallEntry(this.CurrentEvent.MingleAttendees ? HallSectionTypeEnum.NONE : attendee.SectionType);
                    if (aSeat == null)
                    {
                        return;
                    }

                    DormitoryTypeEnum dType = this.attendeesInfo[attendee.UserId].Sex.Trim().ToLower() == "f"
                                              ? DormitoryTypeEnum.WOMEN
                                              : DormitoryTypeEnum.MEN;

                    DormEntry aBed = GetDormEntry(this.CurrentEvent.MingleAttendees ? DormitoryTypeEnum.NONE : dType,
                                                  this.CurrentEvent.MingleAttendees ? DormitoryCategoryEnum.BED : attendee.DormCategory);
                    if (aBed == null)
                    {
                        return;
                    }

                    TableEntry aTable = GetTableEntry(this.CurrentEvent.MingleAttendees ? RegimeEnum.NONE : attendee.TableType);
                    if (aTable == null)
                    {
                        return;
                    }

                    this.attendees[attendeeKey].HallId  = aSeat.HallId;
                    this.attendees[attendeeKey].SeatNbr = aSeat.SeatNbr;

                    this.attendees[attendeeKey].DormitoryId = aBed.DormitoryId;
                    this.attendees[attendeeKey].BedNbr      = aBed.BedNbr;

                    this.attendees[attendeeKey].RefectoryId  = aTable.RefectoryId;
                    this.attendees[attendeeKey].TableId      = aTable.TableId;
                    this.attendees[attendeeKey].TableSeatNbr = aTable.SeatNbr;

                    this.attendees[attendeeKey].SharingGroupNbr = gshare.Place + 1; //+1 because groups are numbered from 0on...

                    this.attendees[attendeeKey].Persist();                          //save data in DB
                    nbAssignment++;
                }
            }

            //Just a check to make sure all attendees have been assigned
            if (nbAssignment != nbrAttendees)
            {
                throw new System.NullReferenceException(string.Format("Failure to generate badges for all registered participants of the event at {0}, starting on {1}"
                                                                      , this.CurrentEvent.Place
                                                                      , this.CurrentEvent.StartDate.ToString()));
            }
        }