public ActionResult Set(Guid id, Double lat, Double lng) { using (DataContext dataContext = new DataContext()) { Station station = dataContext.Stations.Find(id); if (station == null) { return(this.Json(new { success = false, message = "Station not found`" })); } HandledStation handledStation = dataContext.HandledStations.FirstOrDefault(q => q.StationID == id); if (handledStation == null) { handledStation = new HandledStation() { StationID = id, UpdateTime = DateTime.Now }; dataContext.HandledStations.Add(handledStation); } station.Lat = lat; station.Lng = lng; dataContext.SaveChanges(); return(this.Json(new { success = true })); } }
public ActionResult Set(Guid id, Double lat, Double lng) { using (DataContext dataContext = new DataContext()) { Station station = dataContext.Stations.Find(id); if (station == null) { return this.Json(new { success = false, message = "Station not found`" }); } HandledStation handledStation = dataContext.HandledStations.FirstOrDefault(q => q.StationID == id); if (handledStation == null) { handledStation = new HandledStation() { StationID = id, UpdateTime = DateTime.Now }; dataContext.HandledStations.Add(handledStation); } station.Lat = lat; station.Lng = lng; dataContext.SaveChanges(); return this.Json(new { success = true }); } }