public Models.Response.AgendadosResponse ParaResponseAgendados(Models.TbAgendamento agendamento)
        {
            Models.Response.AgendadosResponse resp = new Models.Response.AgendadosResponse();

            resp.idCliente = agendamento.IdClienteNavigation.IdCliente;
            resp.Marca     = agendamento.IdCarroNavigation.DsMarca;
            resp.Modelo    = agendamento.IdCarroNavigation.DsModelo;
            resp.Data      = agendamento.DtAgendamento;
            resp.Cliente   = agendamento.IdClienteNavigation.NmCliente;
            resp.Nota      = agendamento.NrAvaliacao;

            if (agendamento.IdFuncionarioNavigation == null)
            {
                resp.Funcionario = string.Empty;
            }
            else
            {
                resp.Funcionario = agendamento.IdFuncionarioNavigation.NmFuncionario;
            }

            resp.idAgendamento = agendamento.IdAgendamento;
            resp.Situacao      = agendamento.DsSituacao;

            return(resp);
        }
        // Cadastrar

        public Models.TbAgendamento CadastrarClienteAgendamento(Models.TbAgendamento req)
        {
            ctx.TbAgendamento.Add(req);
            ctx.SaveChanges();

            return(req);
        }
Example #3
0
        public Models.TbAgendamento AprovarAgendamento(Models.TbAgendamento agendamento)
        {
            agendamento.DsSituacao = "Aprovado";

            ctx.SaveChanges();
            return(agendamento);
        }
        public string AgendarNovo(Models.TbAgendamento request)
        {
            ctx.TbAgendamento.Add(request);
            ctx.SaveChanges();

            return(this.PegarEmail(request.IdCliente));
        }
 public Models.TbAgendamento RemoverPorId(int idagendamento)
 {
     Models.TbAgendamento agendamento = this.ConsultarPorId(idagendamento);
     bd.Remove(agendamento);
     bd.SaveChanges();
     return(agendamento);
 }
Example #6
0
 public Models.TbAgendamento Feedback(Models.Request.TestDriveRequest.RequestFeedback req, int id)
 {
     Models.TbAgendamento fed = ctx.TbAgendamento.FirstOrDefault(x => x.IdAgendamento == id);
     fed.VlFeedback = req.Feedback;
     ctx.SaveChanges();
     return(fed);
 }
Example #7
0
        public Models.TbAgendamento Cadastrar(int id, Models.TbAgendamento tb)
        {
            if (db.ConsultaCliente(id) == null)
            {
                throw new ArgumentException("Cliente não encontrado");
            }

            if ((tb.DtAgendamento - DateTime.Now).TotalDays < 0)
            {
                throw new ArgumentException("Data invalida");
            }

            if (tb.DtAgendamento.Year > 2021)
            {
                throw new ArgumentException("Data invalida");
            }

            if (db.ConsultarVeiculo(tb.IdVeiculo) == null)
            {
                throw new ArgumentException("Veiculo não encontrado");
            }

            tb.IdCliente = db.ConsultaCliente(id).IdCliente;
            return(db.Cadastrar(tb));
        }
Example #8
0
 public Models.TbAgendamento AlterarSituacao(int idAgendamento, string Situacao)
 {
     Models.TbAgendamento tabela = ctx.TbAgendamento.FirstOrDefault(x => x.IdAgendamento == idAgendamento);
     tabela.DsSituacao = Situacao;
     ctx.SaveChanges();
     return(tabela);
 }
        public Models.TbAgendamento CadastrarAgendamento(Models.TbAgendamento dados)
        {
            bd.Add(dados);
            bd.SaveChanges();

            return(dados);
        }
Example #10
0
        public Models.Response.AgendaResponse RemoverController(int idagendamento)
        {
            Models.TbAgendamento           removido = funcaoBusiness.RemoverAgendamentos(idagendamento);
            Models.Response.AgendaResponse result   = Conversor.Convert(removido);

            return(result);
        }
Example #11
0
 public Models.TbAgendamento AlterarAvaFeed(int id, int avaliacao, string feedback)
 {
     Models.TbAgendamento ag = this.ConsultarAgendamento(id);
     ag.NrAvaliacao = avaliacao;
     ag.DsFeedback  = feedback;
     ctx.SaveChanges();
     return(ag);
 }
Example #12
0
        public void AvaliarTestDriver(int id, Models.Request.AvaliacaoRequest nota)
        {
            Models.TbAgendamento agendamento = ctx.TbAgendamento.FirstOrDefault(x => x.IdAgendamento == id);

            agendamento.NrAvaliacao = nota.Nota;

            ctx.SaveChanges();
        }
        public void ColocarCarroComoDisponivel(int idAgendamento)
        {
            Models.TbAgendamento agendamento = ctx.TbAgendamento.Include(x => x.IdCarroNavigation).FirstOrDefault(x => x.IdAgendamento == idAgendamento);

            agendamento.IdCarroNavigation.QtdDisponivel++;

            ctx.SaveChanges();
        }
        public Models.Response.AgendamentoResponse AgendaResponse(Models.TbAgendamento tbs, string Carro)
        {
            Models.Response.AgendamentoResponse resp = new Models.Response.AgendamentoResponse();

            resp.Data  = tbs.DtAgendamento;
            resp.Carro = Carro;
            return(resp);
        }
        public Models.TbAgendamento Remarcar(DateTime novoHorario, Models.TbAgendamento agendamento)
        {
            validadorAgendamentos.ValidarDataDoAgendamento(novoHorario, agendamento.IdCliente);
            Database.ValidacoesDatabase dbValidacoes = new Database.ValidacoesDatabase();

            dbValidacoes.ValidarDataAgendamentoParaFuncionarioRemarcar(novoHorario, agendamento.IdFuncionario);

            return(db.Remarcar(novoHorario, agendamento.IdAgendamento));
        }
        public Models.TbAgendamento CadastrarAgendamento(Models.TbAgendamento dados)
        {
            if (dados.DtAgendamento < DateTime.Now)
            {
                throw new ArgumentException("Data não pode ser menor que data atual.");
            }

            return(funcaoDatabase.CadastrarAgendamento(dados));
        }
        public Models.TbAgendamento AlterarAgendamentos(int idagendamento, Models.TbAgendamento agendamento)
        {
            if (idagendamento <= 0)
            {
                throw new ArgumentException("Id do agendamento não foi informado.");
            }

            return(funcaoDatabase.Alterar(idagendamento, agendamento));
        }
        public Models.Response.TestDriveResponse.Aprovar ParaResponseAprovar(Models.TbAgendamento tabela)
        {
            Models.Response.TestDriveResponse.Aprovar aprovar = new Models.Response.TestDriveResponse.Aprovar();
            aprovar.IdAgendamento = tabela.IdAgendamento;
            aprovar.Dia           = tabela.DtAgendamento;
            aprovar.Situacao      = tabela.DsSituacao;

            return(aprovar);
        }
        public Models.TbAgendamento Remarcar(DateTime novoHorario, int idAgendamento)
        {
            Models.TbAgendamento agendamento = this.PegarAgendamento(idAgendamento);
            agendamento.DtAgendamento = novoHorario;

            ctx.SaveChanges();

            return(agendamento);
        }
        public Models.TbAgendamento Deletar(int id)
        {
            Models.TbAgendamento tb = db.ConsultarAgendamento(id);
            if (tb == null)
            {
                throw new ArgumentException("Agendamento não exite");
            }

            return(db.Deletar(tb));
        }
        public Models.TbAgendamento ConsultarAgendamento(int id)
        {
            Models.TbAgendamento ag = db.ConsultarAgendamento(id);
            if (ag == null)
            {
                throw new ArgumentException("ID não encontrado");
            }

            return(ag);
        }
        public string AgendarNovo(Models.TbAgendamento agendamento)
        {
            validadorAgendamentos.ValidarAgendamento(agendamento);

            string email = db.AgendarNovo(agendamento);

            this.MarcarCarroComoIndisponivel(agendamento.IdCarro);

            return(email);
        }
        public void MudarSituacao(int idAgendamento, string situacao)
        {
            Models.TbAgendamento agendamento = ctx.TbAgendamento.FirstOrDefault(x => x.IdAgendamento == idAgendamento);

            agendamento.DsSituacao = situacao;

            ctx.SaveChanges();

            this.ColocarCarroComoDisponivel(idAgendamento);;
        }
 public Models.Response.TestDriveResponse.ClienteAgendar ParaResponseagendar(Models.TbAgendamento ag)
 {
     Models.Response.TestDriveResponse.ClienteAgendar agendar = new Models.Response.TestDriveResponse.ClienteAgendar();
     agendar.Carro       = ag.IdCarroNavigation.DsModelo;
     agendar.Dia         = ag.DtAgendamento;
     agendar.Funcionario = ag.IdFuncionario;
     agendar.Situacao    = ag.DsSituacao;
     agendar.Id          = ag.IdAgendamento;
     return(agendar);
 }
Example #25
0
        public Models.TbAgendamento Cadastrar(Models.TbAgendamento tb)
        {
            ctx.TbAgendamento.Add(tb);
            ctx.SaveChanges();

            this.ConsultarVeiculo(tb.IdVeiculo).BtDisponivel = false;
            ctx.SaveChanges();

            return(tb);
        }
 public Models.Response.TestDriveResponse.Aprovar ParaResponseConsultar(Models.TbAgendamento tabela)
 {
     Models.Response.TestDriveResponse.Aprovar aprovar = new Models.Response.TestDriveResponse.Aprovar();
     aprovar.IdAgendamento = tabela.IdAgendamento;
     aprovar.Dia           = tabela.DtAgendamento;
     aprovar.Situacao      = tabela.DsSituacao;
     aprovar.NomeCliente   = tabela.IdClienteNavigation.NmCliente;
     aprovar.Carro         = tabela.IdCarroNavigation.DsModelo;
     aprovar.CPF           = tabela.IdClienteNavigation.DsCpf;
     return(aprovar);
 }
Example #27
0
 public ActionResult <Models.Response.TestDriveResponse.ResponseFeedback> RealizarFeedback(int id, Models.Request.TestDriveRequest.RequestFeedback req)
 {
     try
     {
         Models.TbAgendamento tb = business.ValidarFeedback(req, id);
         return(conversor.ParaResponseFeedback(tb));
     }
     catch (System.Exception e)
     {
         return(BadRequest(new Models.Response.erro(400, e.Message)));
     }
 }
Example #28
0
        public Models.TbAgendamento ParaAgendamentoTabela(Models.Request.AgendarNovoRequest request)
        {
            Models.TbAgendamento agendamento = new Models.TbAgendamento();
            agendamento.DsSituacao    = "Pendente";
            agendamento.DtAgendamento = request.Data;
            agendamento.IdCarro       = request.IdCarro;
            agendamento.IdFuncionario = null;
            agendamento.IdCliente     = request.IdCliente;
            agendamento.NrAvaliacao   = 0;

            return(agendamento);
        }
        public Models.TbAgendamento ParaTabelaAgenda(Models.Request.TestDriveRequest.Agendar ag, int id, Models.TbCarro car)
        {
            Models.TbAgendamento tb = new Models.TbAgendamento();

            tb.DsSituacao     = "Aguardando aprovação";
            tb.IdCliente      = id;
            tb.BtFeedbackDado = false;
            tb.DtAgendamento  = ag.Agendamento;
            tb.IdCarro        = car.IdCarro;

            return(tb);
        }
Example #30
0
        public Models.TbAgendamento AlterarStatus(int id, string status)
        {
            Models.TbAgendamento ag = this.ConsultarAgendamento(id);
            ag.DsStatus = status;

            if (status == "concluido" || status == "cancelado")
            {
                Models.TbVeiculo veiculo = ctx.TbVeiculo.FirstOrDefault(x => x.IdVeiculo == ag.IdVeiculo);
                veiculo.BtDisponivel = true;
            }

            ctx.SaveChanges();
            return(ag);
        }