コード例 #1
0
        public void TaskNotFoundTest()
        {
            var contest = new Contest
            {
                StartTime  = DateTime.Now.AddDays(-1),
                FinishTime = DateTime.Now.AddDays(1)
            };

            _contestsRepository.Stub(o => o.Get(1)).Return(contest);
            var userInfo = new UserInfo(9, null, null);
            var ex       = Assert.Throws <InvalidOperationException>(() => _service.SubmitSolution(1, "A", 2, new FakeHttpPostedFileBase(), userInfo));

            Assert.That(ex.Message, Is.EqualTo("Task not found"));
        }
コード例 #2
0
        public ActionResult SubmitSolution(SubmitContestSolutionViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.Success = true;
                var userId    = User.Identity.GetUserId <long>();
                var userHost  = Request.UserHostAddress;
                var sessionId = Session.SessionID;
                var userInfo  = new UserInfo(userId, userHost, sessionId);
                _contestsService.SubmitSolution(model.ContestId, model.Label, model.SelectedLanguage, model.File, userInfo);

                _sessionService.SaveSelectedLanguage(model.SelectedLanguage);

                return(Redirect(Request.UrlReferrer.ToString()));
            }

            model.Success   = false;
            model.Languages = _submitSolutionService.GetLanguages();
            return(PartialView("Contests/_SubmitSolution", model));
        }