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 })); }
/// <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)); }
public Task AddCallToActionFilter(string callId, CallToActionFilter filter) { filter.CallToActionId = new ObjectId(callId); return(CallToActionFilters.InsertOneAsync(filter)); }