public async Task <IActionResult> Upload(IFormFile uploadedFile) { string directoria = $"{_appEnvironment.WebRootPath}/Files"; Directory.Delete(directoria, true); Directory.CreateDirectory(directoria); if (uploadedFile != null) { string path = "/Files/" + uploadedFile.FileName; using (var fileStream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create)) { await uploadedFile.CopyToAsync(fileStream); } var dirName = uploadedFile.FileName.Replace(".zip", ""); try { _weatherRepository.AddWeather(path, dirName); } catch (Exception e) { TempData["Message"] = e.Message; return(RedirectToAction("Index")); } } return(Redirect("/")); }
public async Task <WeatherForecast> Add([FromBody] WeatherForecast weather) { var newWeatherForecast = await weatherRepository.AddWeather(weather); await _weatherHub.Clients.All.RefreshWeathers(); await _notificationHub.Clients.All.ShowInfoNotification($"{newWeatherForecast.Date} - {newWeatherForecast.Summary}", "New Weather"); return(newWeatherForecast); }
public void Save(Weather weather) { _weatherRepository.AddWeather(weather); }