示例#1
0
        public async Task <IActionResult> AddFilter(
            [FromRoute] string id,
            [FromForm] DateTime?addedOn,
            [FromForm] DateTime from,
            [FromForm] DateTime to,
            [FromForm] string geojson
            )
        {
            var geometry  = geojson.PolygonFromGeoJson();
            var geohashes = await Geohasher.GenerateCoveringGeohashes(geometry);

            Logger.LogInformation("Geometry converted to {HashCount} geohashes {Hashes}", geohashes.Count, string.Join(",", geohashes));

            var filter = new CallToActionFilter {
                AddedOn         = addedOn ?? DateTime.UtcNow,
                TimeBegin       = from,
                TimeEnd         = to,
                Geometry        = geometry,
                CoveringGeohash = geohashes.ToArray()
            };
            await Mongo.AddCallToActionFilter(id, filter);

            return(RedirectToAction(nameof(ShowCall), "Dashboard", new { id = id }));
        }