Пример #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 }));
        }
Пример #2
0
        /// <summary>
        /// Replaces one existing filter.
        /// </summary>
        public Task ReplaceCallToActionFilter(CallToActionFilter f)
        {
            var filter = Builders <CallToActionFilter> .Filter.Eq(cta => cta.Id, f.Id);

            return(CallToActionFilters.ReplaceOneAsync(filter, f));
        }
Пример #3
0
 public Task AddCallToActionFilter(string callId, CallToActionFilter filter)
 {
     filter.CallToActionId = new ObjectId(callId);
     return(CallToActionFilters.InsertOneAsync(filter));
 }