Exemple #1
0
        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);
        }
Exemple #2
0
        public IActionResult Delete(int id)
        {
            if (id < 1)
            {
                return(NotFound());
            }

            _service.Delete(id);
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public async Task TestMethoDeleteAsync()
        {
            var result = await _editorialService.Delete(Guid.NewGuid());

            result.Should().Be(default(Editorial));
        }