예제 #1
0
        public async Task <IActionResult> CreateQuestion(CreateOrEditQuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var question = Mapper.Map <EvaluationQuestion>(model);
                await _evaluationManager.CreateQuestionAsync(question);

                Notifier.Success("你已成功创建了一条新的技术评测问题记录!");
                return(RedirectToAction(nameof(Questions), new { model.EvaluationId, model.SubjectId }));
            }
            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> EditQuestion(CreateOrEditQuestionViewModel model)
        {
            if (ModelState.IsValid)
            {
                var question = await _evaluationManager.FindQuestionByIdAsync(model.Id.Value);

                if (question == null)
                {
                    return(NotFoundQuestion(model.Id.Value));
                }
                _ = Mapper.Map(model, question);
                await _evaluationManager.UpdateQuestionAsync(question);

                Notifier.Success("你已成功编辑了一条技术评测问题记录!");
                return(RedirectToAction(nameof(Questions), new { model.EvaluationId, model.SubjectId }));
            }
            return(View(model));
        }