예제 #1
0
        public async Task <IActionResult> Delete([FromServices] IPurchaseRepository purchaseRepository, string id)
        {
            try
            {
                var purchase = await purchaseRepository.GetById(id);

                if (purchase == null)
                {
                    _logger.LogInformation($"Pedido com ID: {id} não encontrado.");
                    return(NotFound());
                }

                await purchaseRepository.DeleteAsync(purchase);

                _logger.LogInformation($"Usuário {User?.Identity.Name} Deletou o pedido com Id: {id}.");
                return(NoContent());
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
                return(BadRequest(ex));
            }
        }
예제 #2
0
        public async Task DeleteAsync(int purchaseId)
        {
            Purchase purchase = await _purchaseRepository.GetAsync(purchaseId);

            await _purchaseRepository.DeleteAsync(purchase);
        }