public async Task <IHttpActionResult> AddExam([FromBody] ExamRequest request)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _service.AddAsync(request);

                    await _service.CommitAsync();

                    return(Ok());
                }
                return(BadRequest(ModelState));
            }
            catch (Exception ex)
            {
                await _service.RollbackAsync();

                return(BadRequest(GetError(ex)));
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(Exam exam)
        {
            await _examService.AddAsync(exam);

            return(RedirectToAction("Index"));
        }