public Autor Adicionar(Autor obj) { BeginTransaction(); var returno = _autorService.Adicionar(obj); Commit(); return(returno); }
public ActionResult Adicionar([FromBody] List <AutorViewModel> autor) { try { return(Ok(_service.Adicionar(autor))); } catch (ArgumentException ex) { return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message)); } }
public async Task <IActionResult> Create(AutorViewModel autorViewModel) { if (!ModelState.IsValid) { return(View(autorViewModel)); } var autor = _mapper.Map <Autor>(autorViewModel); await _autorService.Adicionar(autor); if (!OperacaoValida()) { return(View(autorViewModel)); } return(RedirectToAction(nameof(Index))); }