コード例 #1
0
ファイル: ExamsController.cs プロジェクト: hndc9x/FA
        public IActionResult CreateExam([FromBody] RequestCreateExam _exam)
        {
            Exam entity;

            if (ModelState.IsValid)
            {
                entity = _examServices.CreateExam(_exam);
                _examServices.Commit();
                return(Created($"api/exam/{entity.Id}", _exam));
            }
            else
            {
                return(BadRequest());
            }
        }
コード例 #2
0
        private async Task HandleSubmit(EditContext editContext)
        {
            var res = await ExamServices.CreateExam(_model);

            if (res != ErrorCodes.Success)
            {
                await Modal.ErrorAsync(new ConfirmOptions()
                {
                    Title   = "Error",
                    Content = ErrorCodes.MessageMap[res]
                });
            }
            else
            {
                await Modal.SuccessAsync(new ConfirmOptions()
                {
                    Title   = "Success",
                    Content = "Click 'OK' to add questions to exam"
                });
            }
        }