Exemple #1
0
        public void SetRoomCap(int locationId, int occurrenceId, int roomCap, bool includeLeaders)
        {
            /// save room cap
            var l = new Arena.Organization.Location(locationId);

            l.MaxPeople = roomCap;
            l.IncludeLeadersForMaxPeople = includeLeaders;
            l.Save("ArenaOz");

            /// Check if we need to close/open the locations occurrences
            ///
            List <Occurrence> locationOccurences = new List <Occurrence>();

            locationOccurences.AddRange(Occurrences.Where(x => x.LocationId == locationId));

            foreach (Occurrence o in locationOccurences)
            {
                var occurrence = new Arena.Core.Occurrence(o.Id);
                var occtype    = occurrence.OccurrenceType;

                if (occtype.UseRoomRatios)
                {
                    if (occtype.MinLeaders != 0 || occtype.PeoplePerLeader != 0)
                    {
                        occurrence.PerformRoomRatioActions(Arena.Enums.CheckInAction.CheckIn, "ArenaOz");
                    }
                    else
                    {
                        if (OccurrenceShouldBeClosed(roomCap, includeLeaders, occurrence.GetCurrentCount(Enums.OccurrenceAttendanceType.Person), occurrence.GetCurrentCount(Enums.OccurrenceAttendanceType.Leader)))
                        {
                            occurrence.OccurrenceClosed = true;
                        }
                        else
                        {
                            occurrence.OccurrenceClosed = false;
                        }
                        occurrence.Save("ArenaOz", false);
                    }
                }
            }
        }