public async Task <IActionResult> OnPostSubmit(int?id) { if (!id.HasValue) { return(NotFound()); } var task = taskRepository.GetTask(id.Value); if (task == null) { return(NotFound()); } if (ModelState.IsValid) { var selectedFileExt = InputViewModel.SrcFilePath.Split('.').Last(); var validSrcExt = GetFileExt(InputViewModel.LangCode); if (validSrcExt != selectedFileExt) { ModelState.AddModelError("", "Select file with correct extension!"); return(OnGet(id)); } var userId = User.FindFirst(ClaimTypes.NameIdentifier).Value; var assignee = task.Assignees.FirstOrDefault(x => x.User.Id == userId); string workDir = ""; // upload src to user work dir if (!string.IsNullOrEmpty(assignee.WorkDir)) { workDir = assignee.WorkDir; } else { var tournament = tournamentRepository.GetTournamentByTask(task.TournamentTaskId); workDir = storageManager.GetWorkDir(userId, tournament.TournamentId.ToString(), task.TournamentTaskId.ToString()); assignee.WorkDir = workDir; taskRepository.Update(task); } var srcFilePath = storageManager.CreateSrcFile(workDir, validSrcExt); using (var stream = new FileStream(srcFilePath, FileMode.Create)) { await InputViewModel.SrcFile.CopyToAsync(stream); } var inputFilePath = storageManager.CreateInputFileInWorkDir(workDir); storageManager.CopyInputFileToWorkDir(task.InputFilePath, inputFilePath); var lang = SupportedProgrammingLanguage.Map(InputViewModel.LangCode, out bool langParseSuccess); if (!langParseSuccess) { ModelState.AddModelError("", "Smth went wrong"); return(OnGet(id)); } string processConditionId = Guid.NewGuid().ToString(); assignee.ProcessResultId = processConditionId; taskRepository.Update(task); ProcessCondition processCondition = new ProcessCondition { Id = processConditionId, WorkingDirPath = workDir, Language = lang }; await processManager.ProcessTask(processCondition); var result = processManager.RetrieveProcessResult(processConditionId); ProcessResult(result, task, assignee); } return(OnGet(id)); }