示例#1
0
        public Result Create(QuizQuestionCreateAdminDto dto)
        {
            var result = _validatorCreate.ValidateResult(dto);

            if (!result.Success)
            {
                return(result);
            }

            var entity = Mapper.Map <QuizQuestion>(dto);

            entity.IsActive = true;

            _quizQuestionRepository.Insert(entity);
            _unitOfWork.Commit();

            QuizQuestionCacheManager.ClearCache();

            result.Id = entity.Id;

            return(result.SetSuccess(Messages.RecordSaved));
        }
        public ActionResult AddQuestion(QuizQuestionViewModel model, int id)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            _quizQuestionRepository.Insert(new DataLayer.Entities.QuizQuestion
            {
                ForQuizId    = id,
                QuestionText = model.QuestionText
            });

            return(RedirectToAction("AddQuestion"));
        }