public async Task <ActionResult> Delete(int id) { if (!ModelState.IsValid) { _logger.LogWarning(ModelState.ToString()); return(BadRequest(ModelState)); } try { return(Ok(await _service.Delete(id))); } catch (ArgumentException e) { return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message)); } }
public async Task E_Possivel_Executar_Create() { _serviceMock = new Mock <ILivroServices>(); _serviceMock.Setup(c => c.Delete(LivroObjectDto.Id)).ReturnsAsync(true); _service = _serviceMock.Object; var result = await _service.Delete(LivroObjectDto.Id); Assert.True(result); _serviceMock = new Mock <ILivroServices>(); _serviceMock.Setup(c => c.Delete(It.IsAny <int>())).ReturnsAsync(false); _service = _serviceMock.Object; result = await _service.Delete(Faker.RandomNumber.Next()); Assert.False(result); }
public ActionResult Delete(Guid id) { _livroServices.Delete(id); return(RedirectToAction("Index")); }