Esempio n. 1
0
        /// <summary>
        /// Calls the repository and gets the events from the database using the filter
        /// Then it maps these events into a pointCollection object
        /// </summary>
        /// <param name="filter">Filter that will be used to retrieve data from the database if needed</param>
        /// <returns>The PointCollection</returns>
        private async Task <PointCollection> GetClusterPointCollection(IFilter filter, string dBCacheKey)
        {
            var points = new PointCollection();

            if (points.Exists(dBCacheKey))
            {
                return(points);
            }

            //get list of events from the database. filter is modified in a way it will recieve all pages at once.
            List <IEvent> dataBaseResult = await Repository.GetAllEventsAsync(filter);

            //map the location, name and id properties
            var mapPoints = dataBaseResult.Select(p => new MapPoint()
            {
                X = p.Longitude, Y = p.Latitude, Name = p.Name, Data = p.Id.ToString()
            }).ToList();

            //i tried setting the cacheKey to null and timespan to zero to avoid caching
            //but it does not work that way.
            points.Set(mapPoints, TimeSpan.FromSeconds(300), dBCacheKey);

            //return the points
            return(points);
        }