Пример #1
0
        public async Task <IActionResult> Register(int id, RegisterTestDto registerTestDto)
        {
            registerTestDto.TeacherId = id;
            var test = await testService.RegisterTest(registerTestDto);

            if (test == null)
            {
                return(BadRequest(resourceManager.GetString("Null")));
            }
            return(Ok(test));
        }
Пример #2
0
        public async Task <Test> RegisterTest(RegisterTestDto registerTestDto)
        {
            if (registerTestDto.Name == "")
            {
                return(null);
            }
            var test = new Test();

            if (registerTestDto.AutomaticCountTime == false)
            {
                test = new Test(Int32.Parse(registerTestDto.SubjectId), registerTestDto.AdditionalInfo, registerTestDto.Name
                                , Int32.Parse(registerTestDto.TypeOfTest), registerTestDto.TimeOfTest, registerTestDto.TeacherId, registerTestDto.AutomaticCountTime);
            }
            else
            {
                test = new Test(Int32.Parse(registerTestDto.SubjectId), registerTestDto.AdditionalInfo, registerTestDto.Name
                                , Int32.Parse(registerTestDto.TypeOfTest), "0", registerTestDto.TeacherId, registerTestDto.AutomaticCountTime);
            }
            testRepository.Create(test);
            await testRepository.SaveChangesAsync();

            return(test);
        }