public string AddAlert([FromBody] JObject jObject) { UsersAlerts userAlerts = new UsersAlerts { UserId = jObject.GetValue("UserId").Value <string>(), AlertId = jObject.GetValue("AlertId").Value <int>(), Latitude = jObject.GetValue("Latitude").Value <double>(), Longitude = jObject.GetValue("Longitude").Value <double>(), AlertLevel = (AlertLevel)jObject.GetValue("AlertLevel").Value <int>() }; applicationDbContext.UserAlerts.Add(userAlerts); User user = GetUser(userAlerts.UserId); var updatedAlert = (from alert in applicationDbContext.Alerts where alert.Id == userAlerts.AlertId select alert).FirstOrDefault(); switch (userAlerts.AlertLevel) { case AlertLevel.Critical: updatedAlert.Critical++; AddNotification(user, updatedAlert, "Marked Critical"); break; case AlertLevel.Warning: updatedAlert.Warning++; AddNotification(user, updatedAlert, "Marked Warning"); break; case AlertLevel.FalseAlarm: updatedAlert.FalseAlarm++; AddNotification(user, updatedAlert, "Marked False Alarm"); break; } updatedAlert.LastCheck = DateTime.Now; applicationDbContext.SaveChanges(); var geoJson = GetGeoJson(updatedAlert); updatedAlert.UserAlertStrings = geoJson; return(JsonConvert.SerializeObject(updatedAlert)); }
public Feature Convert(UsersAlerts usersAlerts) { Properties properties = new Properties { AlertLevel = usersAlerts.AlertLevel }; Geometry geometry = new Geometry { coordinates = new double[2] { usersAlerts.Longitude, usersAlerts.Latitude } }; Feature feature = new Feature { properties = properties, geometry = geometry }; return(feature); }