Exemple #1
0
        private static SoundRecord GetSoundLevel()
        {
            int venueId       = _rnd.Next(1, 13);
            int sectionNumber = _rnd.Next(1, 11);
            int seatSectionId = ((venueId - 1) * 10) + sectionNumber;

            // Read SeatCount from SeatSection table for calculated SectionId
            int seatCount = _seatSectionRepository.GetSeatCount(seatSectionId);

            // Generate a SeatNumber between 1 and SeatCount read above
            int seatNumber = _rnd.Next(1, seatCount + 1);
            int deviceId   = seatNumber + _seatSectionRepository.CalculateSum(venueId, seatSectionId);

            DateTime currentDateTime = DateTime.UtcNow;
            int      decibelLevel    = GetDecibelLevel(currentDateTime.Minute, deviceId);

            decimal longitude = 0;
            decimal latitude  = 0;

            // Get venue details from repo
            var venueModel = _venueRepository.GetVenueInformation(venueId);

            if (venueModel != null)
            {
                longitude = venueModel.Longitude;
                latitude  = venueModel.Latitude;
            }

            SoundRecord soundRecord = new SoundRecord
            {
                DateTime = currentDateTime.ToString("o"),
                Location = new SoundRecord.GeoLocation()
                {
                    Type        = "Point",
                    Coordinates = new List <decimal>()
                    {
                        longitude,
                        latitude
                    }
                },
                DecibelLevel = decibelLevel,
                DeviceId     = deviceId,
                VenueId      = venueId,
                Seat         = seatNumber,
                SeatSection  = sectionNumber
            };

            return(soundRecord);
        }