public async Task <ActionResult <CreatedTestResultDto> > Post([FromBody] NewTestResultDto newTestResultDto)
        {
            if (newTestResultDto == null)
            {
                return(BadRequest());
            }

            return(Ok(await testResultService.CreateTestResult(newTestResultDto)));
        }
Example #2
0
        public ActionResult Passing(PassingViewModel model)
        {
            int checkeTestTime = (DateTime.Now - model.StartPassingTest).Minutes * 60 +
                                 (DateTime.Now - model.StartPassingTest).Seconds - 10;

            if (checkeTestTime > model.Time * 60)
            {
                return(Redirect(Url.Action("NotCompleteTest", "Error")));
            }
            var resultModel = _testService.CheckAnswers(model.ToBllTest());
            var entityTest  = _testService.GetTest(model.Id);

            entityTest.GoodAnswers += resultModel.GoodAnswers;
            entityTest.BadAnswers  += resultModel.BadAnswers;
            _testService.UpdateTest(entityTest);
            resultModel.Name          = entityTest.Name;
            resultModel.User          = _userService.GetUserByEmail(User.Identity.Name);
            resultModel.DateCompleted = DateTime.Now;
            _testResultService.CreateTestResult(resultModel);
            return(RedirectToAction("TestComplete", resultModel.ToMvcTestComplete()));
        }