public async Task <IActionResult> UploadDesafio() { string fileName = "Files/Temp/" + _fileManager.GetFilePath() + ".sb2"; FormValueProvider formModel; var viewModel = new CreateDesafioViewModel(); using (var stream = System.IO.File.Create(fileName)) { formModel = await Request.StreamFile(stream); if (stream.Length > 0) { viewModel.DirArchivo = fileName; } } var bindingSuccessful = await TryUpdateModelAsync(viewModel, "", formModel); if (!bindingSuccessful) { _fileManager.DeleteFile(fileName); return(View("../Desafios/Create", viewModel)); } var profesorId = _userService.Get_ProfesorId(User.Claims); var res = (await _desafioService.Create_Desafio(profesorId, viewModel)); if (res) { this.SetAlerts("success-alerts", "El desafío se creó exitosamente"); } else { this.SetAlerts("error-alerts", "Error al crear el desafío"); } return(RedirectToAction("Index", "ProfesorDesafio")); }