Ejemplo n.º 1
0
        public async Task <IActionResult> Delete(int eventoId, int loteId)
        {
            try
            {
                var lote = await _loteService.GetLoteByIdsAsync(eventoId, loteId);

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

                return(await _loteService.DeleteLote(lote.EventoId, lote.Id)
                       ? Ok(new { message = "Lote Deletado" })
                       : throw new Exception("Ocorreu um problem não específico ao tentar deletar Lote."));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Erro ao tentar deletar lotes. Erro: {ex.Message}"));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Delete(int eventoId, int loteId)
        {
            try
            {
                var lote = await _loteService.GetLoteByIdsAsync(eventoId, loteId);

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

                return(await _loteService.DeleteLote(lote.EventoId, lote.Id)
                       ? Ok(new { message = "Lote Deletado" })
                       : BadRequest("Evento não deletado por motivo desconhecido."));
            }
            catch (Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError,
                                       $"Delete: Erro ao tentar deletar lotes. Erro: {ex.Message}"));
            }
        }