Ejemplo n.º 1
0
        public ActionResult Semanal(FormCollection formCollection)
        {
            DateTime data = DateTime.Parse(formCollection["dataRelatorio"]);
            bool     incluiEstacionados = MakeBoolean(formCollection["incluiEstacionado"]);
            int      estacionamentoID   = 1;

            EstacionamentoDAO estacionamentoDAO = new EstacionamentoDAO(conn);
            Estacionamento    est = estacionamentoDAO.BuscarItem("vagas", estacionamentoID);

            if (est != null)
            {
                Semana    semana    = new Semana(data, DayOfWeek.Sunday);
                Relatorio relatorio = new Relatorio(semana, est);

                RegistroDAO registroDAO = new RegistroDAO(conn);
                relatorio.Registros = registroDAO.GeraRelatorio(relatorio);

                relatorio.View = GerarDadosRelatorio(relatorio);
                relatorio.VeiculosFrequentes = (List <Veiculo>)relatorio.Registros.GroupBy(x => x.Veiculo.Placa).Where(x => x.Count() > 1).Select(x => x.FirstOrDefault().Veiculo).ToList();

                ViewData.Model = relatorio;
                return(View());
            }

            return(RedirectToAction("Index", "Gerencia"));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Index do Estacionamento. Versão Gerencial
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            EstacionamentoDAO estacionamentoDAO = new EstacionamentoDAO(conn);

            estacionamento = estacionamentoDAO.BuscarItem("vagas");
            RegistroDAO registroDAO   = new RegistroDAO(conn);
            int         vagasOcupadas = registroDAO.ContaVagasOcupadas(estacionamento.Id);

            ViewBag.VagasTotal       = estacionamento.NumeroDeVagas;
            ViewBag.VagasOcupadas    = vagasOcupadas;
            ViewBag.VagasDisponiveis = estacionamento.NumeroDeVagas - vagasOcupadas;
            ViewBag.Estacionamento   = estacionamento.Endereco;
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Relatorios()
        {
            EstacionamentoDAO estacionamentoDAO = new EstacionamentoDAO(conn);

            estacionamento = estacionamentoDAO.BuscarItem("vagas");
            RegistroDAO registroDAO   = new RegistroDAO(conn);
            int         vagasOcupadas = registroDAO.ContaVagasOcupadas(estacionamento.Id);

            ViewBag.VagasTotal       = estacionamento.NumeroDeVagas;
            ViewBag.VagasOcupadas    = vagasOcupadas;
            ViewBag.VagasDisponiveis = estacionamento.NumeroDeVagas - vagasOcupadas;
            ViewBag.Estacionamento   = estacionamento.Endereco;
            ViewBag.DiaDeHoje        = $"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}";
            return(View());
        }
Ejemplo n.º 4
0
        public ActionResult Index()
        {
            EstacionamentoDAO estacionamentoDAO = new EstacionamentoDAO(conn);

            estacionamento = estacionamentoDAO.BuscarItem("vagas");
            RegistroDAO  registroDAO   = new RegistroDAO(conn);
            int          vagasOcupadas = registroDAO.ContaVagasOcupadas(estacionamento.Id);
            MarcaDAO     marcaDAO      = new MarcaDAO(conn);
            List <Marca> lstMarca      = marcaDAO.ListarItens();

            ViewBag.VagasTotal    = estacionamento.NumeroDeVagas;
            ViewBag.VagasOcupadas = vagasOcupadas;
            ViewData["Marca"]     = lstMarca;

            return(View());
        }
Ejemplo n.º 5
0
        private Veiculo RegistraEntrada(FormCollection formCollection)
        {
            string placa      = formCollection["placaVeiculo"].ToUpper();
            string cliente    = formCollection["nomeCliente"];
            int    modelo     = int.Parse(formCollection["modeloVeiculo"]);
            string observacao = formCollection["observacaoVeiculo"];

            Veiculo veiculo = new Veiculo
            {
                Placa  = placa,
                Modelo = new Modelo {
                    Id = modelo
                },
                Observacao = observacao,
                Cliente    = new Cliente()
            };

            int registroId = 0;

            using (IConnection conn = new Connection())
            {
                EstacionamentoDAO estacionamentoDAO = new EstacionamentoDAO(conn);
                estacionamento = estacionamentoDAO.BuscarItem("vagas");
                RegistroDAO registroDAO   = new RegistroDAO(conn);
                int         vagasOcupadas = registroDAO.ContaVagasOcupadas(estacionamento.Id);

                //Verifica se existem vagas disponiveis
                if (estacionamento.NumeroDeVagas > vagasOcupadas)
                {
                    VeiculoDAO veiculoDAO = new VeiculoDAO(conn);
                    //Verifica se o Veiculo já existe no DB
                    Veiculo verificaVeiculo = veiculoDAO.BuscarItem("placa", veiculo.Placa);

                    if (verificaVeiculo == null)
                    {
                        veiculo = veiculoDAO.Inserir(veiculo);
                    }
                    else
                    {
                        veiculo = verificaVeiculo;
                    }

                    //Verifica se o Veiculo já está estacionado
                    Registro registro = registroDAO.BuscarItem("placa", veiculo.Placa);

                    if (registro == null)
                    {
                        registro = new Registro
                        {
                            DataDeEntrada  = DateTime.Now,
                            Estacionamento = estacionamento,
                            UsuarioEntrada = AutenticaFuncionarioFake(),
                            Veiculo        = veiculo,
                        };

                        Registro novoRegistro = registroDAO.Inserir(registro);
                        registroId = novoRegistro.Id;
                    }
                    conn.FecharConexao();
                }
            }
            return(veiculo);
        }