Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(long id = 0)
        {
            try
            {
                if (id == 0)
                {
                    this.AddAlertDanger("Ocorreu um erro ao deletar este Fornecedor.");
                    return(RedirectToAction(nameof(Index)));
                }

                var empresa = await _servico.Find(id);

                if (empresa != null)
                {
                    _servico.Excluir(empresa);
                    await _servico.SaveChangesAsync();

                    this.AddAlertSuccess("Fornecedor removido com sucesso.");
                    return(RedirectToAction(nameof(Index)));
                }

                this.AddAlertDanger("Fornecedor não encontrada.");
                return(RedirectToAction(nameof(Index)));
            }
            catch (System.Exception e)
            {
                throw e;
            }
        }