public ActionResult Edit(int id, AnuncioModel anuncioModel) { if (ModelState.IsValid) { var anuncio = _mapper.Map <Anuncio>(anuncioModel); _anuncioService.Alterar(anuncio); } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Update(int id, [FromBody] AnuncioDTO command) { try { if (id != command.AnuncioId) { return(BadRequest()); } var result = await _anuncioService.Alterar(command); if (command.Notifications.Any()) { return(BadRequest(command.Notifications)); } return(Ok(result)); } catch (Exception e) { throw e; } }