public ActionResult RemoveQuestionEdit([Bind(Include = "Id,Name,Questions")] ExamCoreViewModel examViewModel, int?questionID)
 {
     ModelState.Clear();
     if (questionID != null)
     {
         examViewModel.Questions.RemoveAt((int)questionID);
     }
     return(View("~/Views/ExamCores/Edit.cshtml", examViewModel));
 }
 public ActionResult AddQuestionEdit([Bind(Include = "Id,Name,Questions")] ExamCoreViewModel examViewModel)
 {
     ModelState.Clear();
     examViewModel.Questions.Add(new QuestionViewModel()
     {
         ExamCoreID = examViewModel.Id
     });
     return(View("~/Views/ExamCores/Edit.cshtml", examViewModel));
 }
 public ActionResult AddAnswerEdit([Bind(Include = "Id,Name,Questions")] ExamCoreViewModel examViewModel, int?questionID)
 {
     ModelState.Clear();
     examViewModel.Questions[(int)questionID].Answers.Add(new AnswerViewModel()
     {
         QuestionID = examViewModel.Questions[(int)questionID].Id
     });
     return(View("~/Views/ExamCores/Edit.cshtml", examViewModel));
 }
 public ActionResult RemoveAnswerCreate([Bind(Include = "Id,Name,Questions")] ExamCoreViewModel examViewModel, int?questionID, int?answerID)
 {
     ModelState.Clear();
     if (questionID != null)
     {
         examViewModel.Questions[(int)questionID].Answers.RemoveAt((int)answerID);
     }
     return(View("~/Views/ExamCores/Create.cshtml", examViewModel));
 }
        public ActionResult Edit([Bind(Include = "Id,Name,Questions,Owner")] ExamCoreViewModel examViewModel)
        {
            ExamCore editedExam = Mapper.Map <ExamCore>(examViewModel);

            if (ModelState.IsValid)
            {
                _examCoreService.Update(editedExam);
                return(RedirectToAction("Index"));
            }
            return(View(examViewModel));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Questions")] ExamCoreViewModel examViewModel)
        {
            ExamCore tmpExam;

            if (ModelState.IsValid)
            {
                tmpExam       = Mapper.Map <ExamCore>(examViewModel);
                tmpExam.Owner = User.Identity.GetUserId();
                _examCoreService.Insert(tmpExam);
                return(RedirectToAction("Details", new { id = tmpExam.Id }));
            }
            return(View(examViewModel));
        }
        // GET: Exams/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ExamCore exam = _examCoreService.Find(id);

            if (exam == null)
            {
                return(HttpNotFound());
            }
            ExamCoreViewModel examVM = Mapper.Map <ExamCoreViewModel>(exam);

            return(View(examVM));
        }
        // GET: Exams/Create
        public ActionResult Create()
        {
            var tmp = new ExamCoreViewModel();

            return(View(tmp));
        }
        public ActionResult CreateAnswerPartial([Bind(Include = "Id,Name")] ExamCoreViewModel model, int?questionID, int?index)
        {
            ViewBag.tmpQuestionID = questionID ?? 0;

            return(PartialView(model));
        }