Esempio n. 1
0
        public static IEnumerable <Message> GetAllInRadius(double latitude, double longitude, int radius)
        {
            if (Collection == null)
            {
                throw new NullReferenceException("Collection could not be found: " + CollectionName);
            }
            var      messages        = Collection.FindAllAs <Message>();
            var      filteredMessags = MessageFilter.GetFilteredMessages(messages, latitude, longitude, radius);
            var      firstMessages   = filteredMessags.OrderBy(msg => msg.SendTime).GroupBy(item => item.GroupId).Select(grp => grp.First());
            DateTime now             = DateTime.Now;

            var lastTwentyFourHoursMessages = firstMessages.Where(msg => msg.SendTime > now.AddHours(-24) && msg.SendTime <= now);

            return(lastTwentyFourHoursMessages);
        }