Example #1
0
 public IServiceActionResult Delete(
     Guid id,
     [FromServices] IFornecedorService service
     )
 {
     ///fornecedor.user = User.Identity.Name;
     return((ServiceActionResult)service.DeleteFornecedor(id));
 }
Example #2
0
        public async Task <IActionResult> Delete(int id)
        {
            try
            {
                var fornecedor = await fornecedorService.GetFornecedorbyIdAsync(id);

                if (fornecedor == null)
                {
                    return(NoContent());
                }

                return(await fornecedorService.DeleteFornecedor(id) ?
                       Ok(new { messagem = "Deletado" }) :
                       throw new Exception("Ocorreu um problem não específico ao tentar deletar Fornecedor."));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Erro ao tentar deletar eventos. Erro: {ex.Message}"));
            }
        }