public async Task <ActionResult <WeatherRepport> > PostReport([FromBody] WeatherReportDto report) { if (report == null) { return(BadRequest(new { errormessage = "Bad report" })); } var place = await _dbController.FindPlaceById(report.PlaceId); if (place.Name == null) { return(BadRequest(new { errormessage = "Place doesnt exist" })); } WeatherRepport newReport = new WeatherRepport(); { newReport.Place = await _dbController.FindPlaceById(report.PlaceId); newReport.PlaceId = report.PlaceId; newReport.AirPressure = report.AirPressure; newReport.Humidity = report.Humidity; newReport.Temp = report.Temp; if (report.Time == default) { newReport.Time = DateTime.Now; } else { newReport.Time = report.Time; } } report.Time = newReport.Time; report.PlaceName = newReport.Place.Name; await _hub.Clients.All.SendAsync("SendReport", report); _dbController.AddAndSaveWeatherReport(newReport); return(Created(newReport.ToString(), newReport)); }
public async Task SendReport(WeatherReportDto report) { await Clients.All.SendAsync("SendReport", report); }