public async Task <IActionResult> UpdateFilter( [FromRoute] string id, [FromRoute] string filterId, [FromForm] DateTime?addedOn, [FromForm] DateTime from, [FromForm] DateTime to, [FromForm] string geojson ) { var filter = await Mongo.GetCallToActionFilter(filterId); if (filter == null || !filter.CallToActionId.ToString().Equals(id)) { return(NotFound()); } var geometry = geojson.PolygonFromGeoJson(); var geohashes = await Geohasher.GenerateCoveringGeohashes(geometry); Logger.LogInformation("Geometry converted to {HashCount} geohashes {Hashes}", geohashes.Count, string.Join(",", geohashes)); filter.AddedOn = addedOn ?? DateTime.UtcNow; filter.TimeBegin = from; filter.TimeEnd = to; filter.Geometry = geometry; filter.CoveringGeohash = geohashes.ToArray(); await Mongo.ReplaceCallToActionFilter(filter); return(RedirectToAction(nameof(ShowCall), "Dashboard", new { id = id })); }
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 })); }