Beispiel #1
0
        public void Excluir(Guid id)
        {
            var categoria = _categoriaService.GetById(id);

            _categoriaService.Delete(categoria);
            Commit();
        }
        public IActionResult Delete(int id)
        {
            try
            {
                _categoriaService.Delete(id);

                if (Notification.GetNotification() != null)
                {
                    var notificationMessage = Notification.GetNotification().Message;
                    Notification.SetEmpty();

                    return(NotFound(new
                    {
                        StatusCode = (int)HttpStatusCode.NotFound,
                        ErrorMessage = notificationMessage
                    }));
                }

                return(Ok());
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, new
                {
                    StatusCode = (int)HttpStatusCode.InternalServerError,
                    ErrorMessage = ex.Message,
                    stackTrace = ex.StackTrace
                }));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> DeleteCiudad(Int32 id)
        {
            //Si el mensaje no se recibe con el usuario y token correcto, rechaza la petición
            if (await ValidateToken() == false)
            {
                return(Unauthorized());
            }

            // intentar eliminar el registro
            try
            {
                var Item = _serviceCategoria.GetById(id);

                if (Item == null)
                {
                    return(NotFound());
                }

                _serviceCategoria.Delete(Item.Result.Value);
            }
            catch (Exception ex)
            {
                return(NotFound(ex.Message));
            }
            return(Ok());
        }
        public HttpResponseMessage Eliminar(Categoria 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 = _categoriaService.GetById(entidad.Id);

                if (entidad != null)
                {
                    _categoriaService.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);
        }
Beispiel #5
0
        public IActionResult Delete(int id)
        {
            if (id < 1)
            {
                return(NotFound());
            }

            _service.Delete(id);
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int id, CategoriaViewModel categoriaViewModel)
        {
            if (id != categoriaViewModel.Id)
            {
                return(NotFound());
            }

            _categoriaService.Delete(id);

            return(RedirectToAction(nameof(Index)));
        }
        private void btnEliminarCategoria_Click(object sender, EventArgs e)
        {
            if (dgCategoria.SelectedRows.Count == 0)
            {
                MessageBox.Show(this, "Seleccione la categoria que desea eliminar", "Error al eliminar",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            cservice.Delete(idCategoria);
            MessageBox.Show("Categoría eliminada");
            ClearFields();
            FillDataGridViewCategoria();
        }
 public async Task <ActionResult> Delete(int id)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState)); //400 bad request - solicitaçao invalidos
     }
     try
     {
         return(Ok(await _service.Delete(id)));
     }
     catch (ArgumentException e)
     {
         return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
     }
 }
Beispiel #9
0
        public IActionResult DeleteCategoria([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var currentCategoria = categoriaService.FindById(new Categoria {
                IdCategoria = id
            });

            if (currentCategoria == null)
            {
                return(NotFound());
            }

            categoriaService.Delete(currentCategoria);

            return(Ok(currentCategoria));
        }
Beispiel #10
0
 public IActionResult Delete(int id)
 {
     return(Ok(_ICategoriaService.Delete(id)));
 }
        public async Task <JsonResult> Delete(int Id)
        {
            await _serService.Delete(Id);

            return(Json(new { status = "Success" }));
        }
 public IActionResult Delete(Guid id)
 {
     categoriaService.Delete(id);
     return(Ok());
 }
Beispiel #13
0
 public IActionResult Delete(int id)
 {
     return(Json(
                _categoriaService.Delete(id)
                ));
 }
Beispiel #14
0
 public void Remover(Guid id)
 {
     _categoriaService.Delete(id);
 }
Beispiel #15
0
 // DELETE: api/Categorias/5
 public Boolean Delete(int id)
 {
     return(sut.Delete(id));
 }
 public void Delete(Guid Id)
 {
     service.Delete(Id);
 }