示例#1
0
        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));
            }
        }
示例#2
0
        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"));
 }