public ObjectResult Excluir(int Codigo)
        {
            var retorno = new MessageReturn();
            var CategoriasVinculadas = _complementoCategoriaService.GetCategorias(Codigo);

            if (CategoriasVinculadas.Count > 0)
            {
                retorno = new MessageReturn {
                    Title = "0", Message = "Esta categoria esta vincula a um complemento, remova o vinculo no cadastro de complemento e tente novamente.", CssClassName = "warning"
                };
                return(new ObjectResult(retorno));
            }
            var result = _categoriaService.Excluir(Codigo);

            if (result == 1)
            {
                retorno = new MessageReturn {
                    Title = "1", Message = "Item excluido com sucesso.", CssClassName = "success"
                };
            }
            else
            {
                retorno = new MessageReturn {
                    Title = "0", Message = "Erro ao excluir item.", CssClassName = "warning"
                };
            }

            return(new ObjectResult(retorno));
        }
Beispiel #2
0
        public async Task <bool> Excluir(int id)
        {
            bool ehCadastrado = false;

            //Categoria categoria = HelpObjectJSon<Categoria>.Deserialize(dataJson);

            ehCadastrado = _categoriaService.Excluir(id);

            return(await Task.FromResult(ehCadastrado));
        }
        public async Task <ActionResult> Delete(CategoriaVM categoria)
        {
            if (categoria.Id <= 0)
            {
                NotificarErro("Id da categoria inválida.");
                return(CustomResponse());
            }

            await _categoriaService.Excluir(categoria.Id);

            return(CustomResponse());
        }