public async Task <ActionResult <Estabelecimento> > GetEstabelecimento(Guid id)
        {
            var estabelecimento = await _estabelecimentoService.Selecionar(id);

            if (estabelecimento == null)
            {
                return(NotFound());
            }

            return(Ok(estabelecimento));
        }
Exemplo n.º 2
0
        public OcorrenciaResultado Executar(Ocorrencia ocorrencia)
        {
            OcorrenciaResultado resultado = new OcorrenciaResultado();

            resultado.EstabelecimentoId = ocorrencia.EstabelecimentoId;

            var veiculo = _veiculoService.Selecionar(ocorrencia.VeiculoId).Result;

            if (veiculo == null)
            {
                resultado.Status = OcorrenciaStatus.VeiculoNaoCadastrado;
            }
            else
            {
                var estabelecimento = _estabelecimentoService.Selecionar(ocorrencia.EstabelecimentoId).Result;

                switch (veiculo.Tipo)
                {
                case VeiculoTipo.Carro:
                    if (ocorrencia.Movimento == TipoMovimento.entrada)
                    {
                        EstacionarCarro(resultado, estabelecimento, ocorrencia);
                    }
                    else
                    {
                        LiberarCarro(resultado, estabelecimento, ocorrencia);
                    }
                    break;

                case VeiculoTipo.Moto:
                    if (ocorrencia.Movimento == TipoMovimento.entrada)
                    {
                        EstacionarMoto(resultado, estabelecimento, ocorrencia);
                    }
                    else
                    {
                        LiberarMoto(resultado, estabelecimento, ocorrencia);
                    }
                    break;
                }

                _estabelecimentoService.Atualizar(ocorrencia.EstabelecimentoId, estabelecimento);

                resultado.PosicoesVagasCarrosAtualizada = estabelecimento.PosicoesVagasCarros;
                resultado.PosicoesVagasMotosAtualizada  = estabelecimento.PosicoesVagasMotos;
            }

            return(resultado);
        }