public Models.Quiz Post([FromBody] Models.Quiz Quiz)
 {
     if (ModelState.IsValid && Quiz.ModuleId == _entityId)
     {
         Quiz = _QuizRepository.AddQuiz(Quiz);
         _logger.Log(LogLevel.Information, this, LogFunction.Create, "Quiz Added {Quiz}", Quiz);
     }
     return(Quiz);
 }
예제 #2
0
        public IHttpActionResult PostQuizModel(QuizModel quizModel)
        {
            if (quizModel == null)
            {
                return(BadRequest(ModelState));
            }

            _quizRepository.AddQuiz(quizModel);
            _quizRepository.Save();

            return(CreatedAtRoute("DefaultApi", new { id = quizModel.Id }, quizModel));
        }
예제 #3
0
        public async Task <IActionResult> AddQuiz(QuizInformation quizInformation)
        {
            var quiz = await _validator.ValidateAsync(quizInformation);

            if (!quiz.IsValid)
            {
                return(BadRequest(quiz.Errors));
            }

            var resultOfRepository = await _repository.AddQuiz(quizInformation);

            return(Ok(resultOfRepository));
        }
        public void ImportModule(Module module, string content, string version)
        {
            List <Models.Quiz> Quizs = null;

            if (!string.IsNullOrEmpty(content))
            {
                Quizs = JsonSerializer.Deserialize <List <Models.Quiz> >(content);
            }
            if (Quizs != null)
            {
                foreach (var Quiz in Quizs)
                {
                    _QuizRepository.AddQuiz(new Models.Quiz {
                        ModuleId = module.ModuleId, Name = Quiz.Name
                    });
                }
            }
        }
예제 #5
0
        public async Task <ActionResult <Quiz> > CreateQuiz(Quiz quiz)
        {
            try
            {
                if (quiz == null)
                {
                    return(BadRequest());
                }

                var createdquiz = await quizRepository.AddQuiz(quiz);

                return(CreatedAtAction(nameof(GetQuizById), new { id = createdquiz.QizId }, createdquiz));
            }
            catch (Exception)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, "Error retriving data "));
            }
        }
예제 #6
0
        public IActionResult CreateQuiz([FromBody] QuizTopic quiz)
        {
            if (quiz == null)
            {
                return(BadRequest());
            }

            if (quiz.Title == string.Empty || quiz.Description == string.Empty)
            {
                ModelState.AddModelError("Title/Description", "The title or description shouldn't be empty");
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var createdQuiz = _quizRepository.AddQuiz(quiz);

            return(Created("quiz", createdQuiz));
        }
예제 #7
0
        public ActionResult Create(QuizModel _Quizmodel)
        {
            if (ModelState.IsValid)
            {
                int id = _quizRepository.AddQuiz(_Quizmodel);

                if (id != 0)
                {
                    ViewBag.Message = "Quiz Created Successfully..!";
                }
                else
                {
                    ViewBag.Message = "Error Creating Quiz..!";
                }


                return(RedirectToAction("UserProfile", "Account"));
            }


            return(View());
        }
예제 #8
0
        public async Task <IActionResult> AddQuiz([FromBody] Models.Quiz quiz)
        {
            var quizExist = await _quizRepository.GetQuizzes(quiz.SchoolId);

            if (quizExist != null && quizExist.Count > 0)
            {
                foreach (var name in quizExist)
                {
                    if (name != null && name.QuizName.ToLower() == quiz.QuizName.ToLower())
                    {
                        return(Conflict($"A quiz with the name {quiz.QuizName} already exists"));
                    }
                }
            }

            if (string.IsNullOrEmpty(quiz.QuizName))
            {
                return(NotFound($"Quiz name is required"));
            }

            var result = _quizRepository.AddQuiz(quiz);

            return(Ok(result));
        }
예제 #9
0
        public async Task <IActionResult> AddQuiz(QuizInformation quizInformation)
        {
            await _repository.AddQuiz(quizInformation);

            return(Ok());
        }