Exemplo n.º 1
0
        public async Task <int> AddAsync(AutorViewModel autorViewModel)
        {
            var autorEntity = _mapper.Map <AutorEntity>(autorViewModel);

            var id = await _autorService.AddAsync(autorEntity);

            return(id);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Post([FromBody] Autor autor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { message = "Erro ao cadastrar autor" }));
            }
            try
            {
                var autorcad = await _autorService.AddAsync(autor);

                return(Ok(autorcad));
            }
            catch (Exception e)
            {
                return(BadRequest(new { message = "Erro buscar autor", exception = e.Message }));
            }
        }