public IActionResult Submit(TeamCodeSubmitModel model) { if (Service.Team is null || Service.Team.Status != 1) { return(Message("Submit", "You don't belong to a team yet.", MessageType.Danger)); } var sid = SubmitCore(model); if (sid == -1) { return(NotFound()); } return(RedirectToAction(nameof(Submission), new { cid = Contest.ContestId, sid })); }
public IActionResult Submit(TeamCodeSubmitModel model) { if (!Contest.StartTime.HasValue || Contest.StartTime.Value >= DateTimeOffset.Now) { return(Message("Submit", "Contest not started.", MessageType.Danger)); } if (SubmitCore(model) == -1) { return(NotFound()); } DisplayMessage = "Submission done! Watch for the verdict in the list below."; return(RedirectToAction(nameof(Home), new { cid = Contest.ContestId })); }
public async Task <IActionResult> Submit( int cid, TeamCodeSubmitModel model, [FromServices] ISubmissionStore submissions) { if (!ViewData.ContainsKey("HasTeam")) { StatusMessage = "You should register first."; return(RedirectToAction(nameof(Register))); } if (TooEarly && !ViewData.ContainsKey("IsJury")) { StatusMessage = "Contest not started."; return(RedirectToAction(nameof(Home))); } var prob = Problems.Find(model.Problem); if (prob is null || !prob.AllowSubmit) { StatusMessage = "Error problem not found."; return(RedirectToAction(nameof(Home))); } var lang = Languages.GetValueOrDefault(model.Language); if (lang == null) { StatusMessage = "Error language not found."; return(RedirectToAction(nameof(Home))); } var s = await Facade.SubmitAsync( code : model.Code, language : lang.Id, problemId : prob.ProblemId, contest : Contest, teamId : Team.TeamId, ipAddr : HttpContext.Connection.RemoteIpAddress, via : "gym-page", username : User.GetUserName()); await Mediator.SubmissionCreated(Contest, s); StatusMessage = "Submission done!"; return(RedirectToAction(nameof(ProblemView), new { prob = prob.ShortName })); }
public async Task <IActionResult> Submit(TeamCodeSubmitModel model) { if (TooEarly && !Contest.IsJury) { ModelState.AddModelError("TimeSequence", "Contest not started."); } var prob = await Context.FindProblemAsync(model.Problem); if (prob is null || !prob.AllowSubmit) { ModelState.AddModelError(nameof(model.Problem), "Problem not found."); } var lang = await Context.FindLanguageAsync(model.Language); if (lang == null) { ModelState.AddModelError(nameof(model.Language), "Language not found."); } if (!ModelState.IsValid) { model.Languages = await Context.ListLanguagesAsync(); model.Problems = await Context.ListProblemsAsync(); return(Window(model)); } var s = await Context.SubmitAsync( code : model.Code, language : lang, problem : prob, team : Contest.Team, ipAddr : HttpContext.Connection.RemoteIpAddress, via : "team-page", username : User.GetUserName()); StatusMessage = "Submission done! Watch for the verdict in the list below."; return(RedirectToAction(nameof(Home))); }
protected int SubmitCore(TeamCodeSubmitModel model) { var problems = Service.Problems; var prob = problems.FirstOrDefault(cp => cp.ShortName == model.Problem); if (prob is null) { return(-1); } var s = new Submission { Author = Service.Team.TeamId, CodeLength = model.Code.Length, ContestId = Contest.ContestId, Ip = HttpContext.Connection.RemoteIpAddress.ToString(), Language = model.Language, ProblemId = prob.ProblemId, Time = DateTimeOffset.Now, SourceCode = model.Code.ToBase64() }; return(Service.CreateSubmission(s)); }