public async Task <IActionResult> DeleteMunicipio([FromRoute] int id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _servicioMunicipio.Delete(id); return(Ok()); }
public async Task <ActionResult> Delete(Guid id) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); //400 bad request - solicitacao inválida } try { return(Ok(await _service.Delete(id))); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public IActionResult Delete(int id) { try { var entity = municipioService.Find(id); if (entity == null) { return(NotFound()); } municipioService.Delete(entity); return(Ok()); } catch (Exception) { throw; } }
public async Task E_Possivel_Executar_Metodo_Delete() { _serviceMock = new Mock <IMunicipioService>(); _serviceMock.Setup(m => m.Delete(IdMunicipio)).ReturnsAsync(true); _service = _serviceMock.Object; var deletado = await _service.Delete(IdMunicipio); Assert.True(deletado); _serviceMock = new Mock <IMunicipioService>(); _serviceMock.Setup(m => m.Delete(It.IsAny <Guid>())).ReturnsAsync(false); _service = _serviceMock.Object; deletado = await _service.Delete(Guid.NewGuid()); Assert.False(deletado); }