Example #1
0
        public AlterarPlanoVooResponse Alterar(AlterarPlanoVooRequest request)
        {
            if (!VerificaRequest(request, "AlterarPlanoVooRequest"))
            {
                return(null);
            }

            PlanoVoo planovoo = _repositoryPlanoVoo.ObterPorId(request.Id);

            if (planovoo == null)
            {
                AddNotification("Id", Message.DADOS_NAO_ENCONTRADOS);
                return(null);
            }

            planovoo.AlterarPlanoVoo(request.IdAeroportoOrigem, request.IdAeroportoDestino, request.IdAeronave, request.IdVoo);

            AddNotifications(planovoo);

            if (this.IsInvalid())
            {
                return(null);
            }

            return((AlterarPlanoVooResponse)planovoo);
        }
Example #2
0
        public PlanoVooResponse Consultar(Guid id)
        {
            if (!VerificaRequest(id, "Id"))
            {
                return(null);
            }

            PlanoVoo planovoo = _repositoryPlanoVoo.ObterPorId(id);

            if (planovoo == null)
            {
                AddNotification("Id", Message.DADOS_NAO_ENCONTRADOS);
                return(null);
            }

            return(_repositoryPlanoVoo.Consultar(id).FirstOrDefault());
        }
Example #3
0
        public async Task <bool> AtualizarAsync(PlanoVoo entidade)
        {
            try
            {
                using (var conn = _conn.GetConnection())
                {
                    await conn.ExecuteAsync("EXEC ATUALIZAR_PLANO_VOO @IDPLANOVOO, @NUMEROVOO, @DATA, @IDAERONAVE, @IDAEROPORTOORIGEM, @IDAEROPORTODESTINO", entidade);

                    return(true);
                }
            }
            catch (Exception e)
            {
                _log.LogError(e);
                return(false);
            }
        }
Example #4
0
        public async Task <bool> RemoverAsync(PlanoVoo entidade)
        {
            try
            {
                using (var conn = _conn.GetConnection())
                {
                    await conn.ExecuteAsync("EXEC EXCLUIR_PLANO_VOO @IDPLANOVOO", entidade);

                    return(true);
                }
            }
            catch (Exception e)
            {
                _log.LogError(e);
                return(false);
            }
        }
Example #5
0
        public BaseResponse Excluir(Guid id)
        {
            if (!VerificaRequest(id, "Id"))
            {
                return(null);
            }

            PlanoVoo planovoo = _repositoryPlanoVoo.ObterPorId(id);

            if (planovoo == null)
            {
                AddNotification("Id", Message.DADOS_NAO_ENCONTRADOS);
                return(null);
            }

            _repositoryPlanoVoo.Remover(planovoo);

            return(new BaseResponse());
        }
Example #6
0
        public AdicionarPlanoVooResponse Adicionar(AdicionarPlanoVooRequest request)
        {
            if (!VerificaRequest(request, "AdicionarPlanoVooRequest"))
            {
                return(null);
            }

            PlanoVoo planovoo = new PlanoVoo(request.IdAeroportoOrigem, request.IdAeroportoDestino, request.IdAeronave, request.IdVoo);

            AddNotifications(planovoo);

            if (this.IsInvalid())
            {
                return(null);
            }

            planovoo = _repositoryPlanoVoo.Adicionar(planovoo);

            return((AdicionarPlanoVooResponse)planovoo);
        }