public HttpResponseMessage Eliminar(Editorial entidad) { var resultado = (HttpResponseMessage)null; try { if (entidad == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = "El modelo no puede ser nulo" })); } if (entidad.Id < 1) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new { message = "El id debe ser amyor a 0" })); } entidad = _editorialService.GetById(entidad.Id); if (entidad != null) { _editorialService.Delete(entidad); resultado = Request.CreateResponse(HttpStatusCode.OK, 1); } else { resultado = Request.CreateResponse(HttpStatusCode.OK, 0); } } catch (Exception exception) { resultado = Request.CreateResponse(HttpStatusCode.InternalServerError, new { message = exception.Message }); } return(resultado); }
public IActionResult Delete(int id) { if (id < 1) { return(NotFound()); } _service.Delete(id); return(RedirectToAction("Index")); }
public async Task TestMethoDeleteAsync() { var result = await _editorialService.Delete(Guid.NewGuid()); result.Should().Be(default(Editorial)); }