public IActionResult Create(SubmissionCreateViewModel model) { if (!this.ModelState.IsValid) { return(this.Redirect("/Submissions/Create")); } var problem = this.problemsService.GetById(model.ProblemId); var user = this.usersService.GetById(User.Id); var rnd = new Random(); var randomScore = rnd.Next(0, problem.Points); var submission = new Submission() { AchievedResult = randomScore, Code = model.Code, CreatedOn = DateTime.UtcNow, UserId = User.Id, ProblemId = problem.Id }; this.submissionsService.Create(submission); return(this.Redirect("/")); }
public IActionResult Create(string id) { Problem problem = _context.Problems.FirstOrDefault(a => a.Id == id); var viewModel = new SubmissionCreateViewModel { ProblemId = problem.Id, ProblemName = problem.Name }; return(View(viewModel)); }
public IActionResult Create(string id) { var problem = this.problemService.GetProblemById(id); var viewModel = new SubmissionCreateViewModel { Name = problem.Name, ProblemId = problem.Id }; return(this.View(viewModel)); }
public HttpResponse Create(string id) { var problem = this.problemsService.GetProblemById(id); var model = new SubmissionCreateViewModel() { Name = problem.Name, ProblemId = problem.Id }; return(this.View(model)); }
public async Task <ActionResult> Submit(SubmissionCreateViewModel submission) { if (!this.ModelState.IsValid) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var dbSubmission = this.submissions.Create(this.LoggedUser, Guid.Parse(submission.ChallengeId), submission.SourceCode); // Code Execution var tests = this.tests.GetByChallenge(dbSubmission.ChallengeId); var testsResultIdentifiers = await this.executionService.EvaluateTests(dbSubmission.SourceCode, dbSubmission.Challenge.Language, tests.Select(x => x.Input)); this.testResults.CreateTestResults(dbSubmission, tests.ToList(), testsResultIdentifiers.Select(x => x.Id).ToList()); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
public IActionResult Create(string Id) { var problem = this.problemService.GetProblemById(Id); if (problem == null) { this.Redirect("/"); } var viewModel = new SubmissionCreateViewModel() { Name = problem.Name, ProblemId = problem.Id }; return(this.View(viewModel)); }
public HttpResponse Create(string id) { if (!this.IsLoggedIn()) { return(this.Redirect(this.homeUrl)); } var problem = this.problemsService.GetById(id); if (problem == null) { return(this.Redirect(this.homeUrl)); } var inputModel = new SubmissionCreateViewModel { Name = problem.Name, ProblemId = id, }; return(this.View(inputModel, "Create")); }
public HttpResponse Create(string id) { if (!this.IsUserLoggedIn()) { return(this.Redirect("/Users/Login")); } var problem = this.problemsService.GetById(id); if (problem == null) { return(this.Error("We can't find this problem")); } var submissionCreateViewModel = new SubmissionCreateViewModel { Name = problem.Name, ProblemId = problem.Id }; return(this.View(submissionCreateViewModel)); }