public IActionResult Create([FromBody] MeasurementModel model) { try { var weatherStation = _measurementService.FindWeatherStation(model.Location.Name); if (weatherStation == null) { weatherStation = new LocalWeatherStation { Name = model.Location.Name, Longitude = model.Location.Longitude, Latitude = model.Location.Latitude }; } var measurement = new Measurement { LocalWeatherStation = weatherStation, Temperature = model.Temperature, AirPressure = model.AirPressure, Humidity = model.Humidity, Time = DateTime.ParseExact(model.Time, "dd-MM-yyyy HH:mm:ss", null) }; if (weatherStation.Measurements == null) { weatherStation.Measurements = new List <Measurement>(); } weatherStation.Measurements.Add(measurement); _measurementService.Create(measurement); // Notify Hub _chatHub.Clients.All.SendAsync("ReceiveMessage", "New Data in ", model.Location.Name); return(RedirectToAction(nameof(Index))); } catch { return(NotFound()); } }