public ActionResult Save(EpisodeQuizEngineDTO entity)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    ValidateModel(entity);

                    EpisodeQuizEngineService.Instance.CreateOrUpdate(entity);

                    Success("Quiz salvo com sucesso.");
                }
                else
                {
                    ModelState.AddModelError("", "Alguns campos são obrigatórios para salvar o quiz.");

                    return(PartialView("_Edit", entity));
                }
            }
            catch (Exception ex)
            {
                Error("Houve um erro ao salvar o quiz.");

                Logger.LogException(ex);

                ModelState.AddModelError("", "Ocorreu um erro ao tentar salvar o quiz.");

                return(PartialView("_Edit", entity));
            }

            return(new EmptyResult());
        }
        public ActionResult Edit(string quizId)
        {
            EpisodeQuizEngineDTO quiz = EpisodeQuizEngineService.Instance.GetById(quizId);

            ViewBag.Metrics = GetMetricsToSelect(quiz.MetridID);

            return(PartialView("_Edit", quiz));
        }
        public ActionResult Create(string episodeId)
        {
            EpisodeQuizEngineDTO quiz = new EpisodeQuizEngineDTO();

            ViewBag.Metrics = GetMetricsToSelect(null);

            quiz.EpisodeId = episodeId;

            return(PartialView("_Edit", quiz));
        }
        public ActionResult Remove(string quizId)
        {
            EpisodeQuizEngineDTO quiz = EpisodeQuizEngineService.Instance.GetById(quizId);

            try
            {
                EpisodeQuizEngineService.Instance.DeleteById(quizId);
            }
            catch (Exception e)
            {
                Error("Ocorreu um erro ao remover.");
            }

            ViewBag.NumberOfQuiz = EpisodeQuizEngineService.Instance.GetByEpisodeId(quiz.EpisodeId).List.quizSheet.Count;

            return(View("Index"));
        }
 public EpisodeQuizEngineDTO CreateOrUpdate(EpisodeQuizEngineDTO quiz)
 {
     return(PostDTO <EpisodeQuizEngineDTO>(ref quiz));
 }