Пример #1
0
        public ActionResult Create(AgendamentoViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                vm = new AgendamentoViewModel
                {
                    Medicos   = _context.Medicos.ToList(),
                    Pacientes = _context.Pacientes.ToList(),
                    Data      = DateTime.Now.ToShortDateString().ToString(),
                    Hora      = DateTime.Now.ToShortTimeString().ToString()
                };
                return(View("Create", vm));
            }

            var agenda = new Agendamento
            {
                UsuarioId  = User.Identity.GetUserId(),
                Data       = vm.DateTime(),
                MedicoID   = vm.Medico,
                PacienteID = vm.Paciente
            };

            _context.Agendamentos.Add(agenda);
            _context.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Пример #2
0
        private void bindingNavigatorDeleteItem_Click(object sender, EventArgs e)
        {
            Agendamento agendamento = (Agendamento)bsAgendamento.Current;

            if (agendamento != null)
            {
                try
                {
                    // verifica se o registro é algum default que não pode ser deletado
                    if (agendamento.Id == 1)
                    {
                        throw new ArgumentException("Não é possível excluir esse registro padrão.");
                    }

                    control.RemoverObjeto((Agendamento)bsAgendamento.Current);
                }
                catch (ArgumentException ex)
                {
                    MessageBox.Show(ex.Message, "Erro Interno", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                catch (DbUpdateException ex)
                {
                    MessageBox.Show("Não é possível deletar o Registro. Há outros dados vinculados a ele.", "Erro Interno", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Não foi possível deletar o registro. Tente novamente.", "Erro Interno", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }

            this.binding();
        }
Пример #3
0
        public void BD_como_atendente_devo_registrar_um_agendamento_e_obter_o_mesmo_agendamento()
        {
            //arrenge
            IRepositorioAgendamento repAgendamento;
            IRepositorioPaciente    repPaciente;
            Contexto           ctx;
            ServicoAgendamento servicoAgendamento;

            //act
            ctx                = new Contexto();
            repPaciente        = new RepositorioPaciente(ctx);
            repAgendamento     = new RepositorioAgendamento(ctx);
            servicoAgendamento = new ServicoAgendamento(repAgendamento, repPaciente);

            var paciente = repPaciente.obterPaciente("1");
            var data     = DateTime.Now;

            data = data.AddDays(5);
            var agendamento = new Agendamento(paciente, data, ETipoDeTratamento.Quimioterapia_Dia);
            var funfou      = servicoAgendamento.registrarAgendamento(agendamento);

            //assert
            Assert.IsTrue(funfou);
            Assert.IsTrue(repAgendamento.obterAgendamentos().Contains(agendamento));
        }
Пример #4
0
        private void agendamentoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Agendamento Agenda = new Agendamento();

            Agenda.MdiParent = this;
            Agenda.Show();
        }
Пример #5
0
        public async Task <IActionResult> Edit(int id, [Bind("AgendaId,Nome,DataNascimento,DataHoraInicio,DataHoraFim,Observacao")] Agendamento agendamento)
        {
            if (id != agendamento.AgendaId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agendamento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgendamentoExists(agendamento.AgendaId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(agendamento));
        }
Пример #6
0
        public async Task <ActionResult <Agendamento> > PostAgendamentoAsync(Agendamento agendamento)
        {
            _context.Agendamentos.Add(agendamento);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetAgendamentoAsync), new { idagendamento = agendamento.IdAgendamento }, agendamento));
        }
        public List <Agendamento> ObterAgendamentos()
        {
            var linhas = File.ReadAllLines(PATH);
            List <Agendamento> agendamentos = new List <Agendamento>();

            foreach (var linha in linhas)
            {
                Agendamento agendamento = new Agendamento();

                agendamento.PrecoTotal = 900;

                agendamento.Cliente.Nome        = ExtrairValorDoCampo("cliente_Nome", linha);
                agendamento.Cliente.Endereco    = ExtrairValorDoCampo("cliente_Endereco", linha);
                agendamento.Cliente.Telefone    = ExtrairValorDoCampo("cliente_Telefone", linha);
                agendamento.Cliente.Email       = ExtrairValorDoCampo("cliente_Email", linha);
                agendamento.NomeEvento          = ExtrairValorDoCampo("evento_Nome", linha);
                agendamento.Cliente.TipoUsuario = uint.Parse(ExtrairValorDoCampo("cliente_TipoUsuario", linha));
                agendamento.DataDoEvento        = DateTime.Parse(ExtrairValorDoCampo("date_pedido", linha));
                agendamento.PrecoTotal          = double.Parse(ExtrairValorDoCampo("preco_Total", linha));


                agendamentos.Add(agendamento);
            }
            return(agendamentos);
        }
Пример #8
0
        public async Task <Agendamento> EditarAsync(Agendamento agendamento)
        {
            _context.Entry <Agendamento>(agendamento).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(agendamento);
        }
Пример #9
0
        public string RetornarEmailCliente(int usuarioId, Agendamento agendamento)
        {
            string emailConta = RetornarEmailConta(usuarioId);

            if (string.IsNullOrWhiteSpace(emailConta))
            {
                return("");
            }

            var listaEmail = BuscarEmailClientes(agendamento.Id);

            int contador = 0;

            if (listaEmail != null)
            {
                foreach (var item in listaEmail)
                {
                    AdicionarEmailCliente(item.Email);
                    contador++;
                }
            }

            if (contador == 0)
            {
                AdicionarEmailCliente(emailConta);
            }

            return(RetornaListaEmail(_listaEmailCliente));
        }
Пример #10
0
        private void RetornarEmailConsultor(int usuarioId, Agendamento agendamento)
        {
            var notificar = new StatusServico().NotificarConsultor(agendamento.StatusId);

            if (notificar)
            {
                if (agendamento.Cliente == null)
                {
                    agendamento.Cliente = new ClienteServico().ObterPorId(agendamento.ClienteId);

                    if (agendamento.Cliente == null)
                    {
                        return;
                    }
                }

                int idUsuario = 0;
                if (agendamento.Cliente.UsuarioId != null)
                {
                    idUsuario = Convert.ToInt32(agendamento.Cliente.UsuarioId);
                }

                var usuarioModel = new UsuarioServico().ObterPorId(idUsuario);

                if (usuarioModel == null)
                {
                    return;
                }

                if (!string.IsNullOrEmpty(usuarioModel.Email))
                {
                    Adicionar(usuarioModel.Email);
                }
            }
        }
Пример #11
0
        public void Salvar(Agendamento model)
        {
            ValidarAgendamento(model);

            _rep.Salvar(model);
            _rep.Commit();
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,HoraAtendimento,TempoAtemdimento,DentistaId,PacienteId,SecretariaId")] Agendamento agendamento)
        {
            if (id != agendamento.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _agendaOdontologica.Update(agendamento);
                    await _agendaOdontologica.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgendamentoExists(agendamento.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DentistaId"]   = new SelectList(_agendaOdontologica.Dentistas, "Id", "Id", agendamento.DentistaId);
            ViewData["PacienteId"]   = new SelectList(_agendaOdontologica.Pacientes, "Id", "Id", agendamento.PacienteId);
            ViewData["SecretariaId"] = new SelectList(_agendaOdontologica.Secretarias, "Id", "Id", agendamento.SecretariaId);
            return(View(agendamento));
        }
Пример #13
0
        public async System.Threading.Tasks.Task EnviarAgendamento(Agendamento agendamento)
        {
            HttpClient cliente = new HttpClient();

            var dataHotaAgendamento = new DateTime(
                agendamento.DataAgendamento.Year, agendamento.DataAgendamento.Month, agendamento.DataAgendamento.Day,
                agendamento.HoraAgendamento.Hours, agendamento.HoraAgendamento.Minutes, agendamento.HoraAgendamento.Seconds
                );
            var Json = JsonConvert.SerializeObject(new
            {
                nome            = agendamento.Nome,
                fone            = agendamento.Fone,
                email           = agendamento.Email,
                carro           = agendamento.Modelo,
                preco           = agendamento.Preco,
                dataAgendamento = dataHotaAgendamento
            });

            var conteudo = new StringContent(Json, Encoding.UTF8, "application/json");

            var resposta = await cliente.PostAsync(URL_POPSAGENDAMENTO, conteudo);

            agendamento.Confirmado = resposta.IsSuccessStatusCode;

            SalvarAgendamentoDB(agendamento);

            if (agendamento.Confirmado)
            {
                MessagingCenter.Send <Agendamento>(agendamento, "SucessoAgendamento");
            }
            else
            {
                MessagingCenter.Send <ArgumentException>(new ArgumentException(), "FalhaAgendamento");
            }
        }
        protected void btn_Cancelar_Click(object sender, EventArgs e)
        {
            Button btn = sender as Button;

            try
            {
                using (DatabaseEntities context = new DatabaseEntities())
                {
                    int         id          = int.Parse(btn.CommandArgument);
                    Agendamento agendamento = context.Agendamento.Where(a => a.idAgendamento == id).FirstOrDefault();
                    agendamento.status = "Cancelado pelo cliente";
                    context.SaveChanges();
                    preencherTabela();
                    pnl_Alert.CssClass = "alert alert-success";
                    lbl_Alert.Text     = "Agendamento cancelado";
                    pnl_Alert.Visible  = true;
                }
            }
            catch (Exception ex)
            {
                pnl_Alert.CssClass = "alert alert-danger";
                lbl_Alert.Text     = "Erro: " + ex.Message + Environment.NewLine + "Por favor entre em contato com o suporte";
                pnl_Alert.Visible  = true;
            }
        }
Пример #15
0
        public IActionResult Editar(int id, Agendamento model)
        {
            if (id != model.Id)
            {
                return(NotFound());
            }
            try
            {
                Agendamento agendamento = _context.Agendamentos.Find(id);
                agendamento = model;

                _context.Agendamentos.Update(agendamento);
                _context.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AgendamentoExists(model.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToAction(nameof(Index)));
        }
Пример #16
0
        public IActionResult Registrar1(IFormCollection form)
        {
            ViewData["nomeView"] = "Formulario1";
            Agendamento agendamento = new Agendamento();

            Cliente cliente = new Cliente()
            {
                Nome     = form["nome"],
                Cpfcnpj  = form["cpfcnpj"],
                Telefone = form["telefone"],
                Email    = form["email"]
            };

            Evento evento = new Evento()
            {
                tipoEvento      = form["tipoEvento"],
                dataEvento      = DateTime.Parse(form["dataEvento"]),
                inicioEvento    = form["inicioEvento"],
                terminoEvento   = form["terminoEvento"],
                numPessoas      = form["numPessoas"],
                descricaoEvento = form["descricaoEvento"]
            };

            agendamento.Cliente      = cliente;
            agendamento.Evento       = evento;
            agendamento.Pagamento    = new Pagamento();
            agendamento.DataDoPedido = DateTime.Now;
            agendamento.PrecoTotal   = 0.0;

            var linha = agendamentoRepositorio.PrepararPedidoCSV(agendamento);

            HttpContext.Session.SetString("agendamento", linha);

            return(RedirectToAction("Formulario2"));
        }
Пример #17
0
        private string PrepararRegistroCSV(Agendamento agendamento)
        {
            Cliente cliente = agendamento.Cliente;
            Evento  evento  = agendamento.Evento;

            return($"id={evento.Id};status_pedido={evento.Status};cliente_nome={cliente.Nome};cliente_cpfcnpj={cliente.CpfCnpj};cliente_telefone={cliente.Telefone};cliente_email={cliente.Email};evento_tema={evento.Tema};evento_data={evento.DataDoAgendamento};evento_quantidadePessoas={evento.NumeroDePessoas};evento_tipo={evento.TipoDoEvento};evento_servicos={evento.Servicos};evento_descricao={evento.Descricao}");
        }
Пример #18
0
        public void AtualizarEstado(uint id, string NovoEstado)
        {
            //TODO PEGA O AGENDAMENTO
            Agendamento agendamento = ObterPor(id);
            int         linha       = 0;

            //TODO MUDA O ESTADO DO AGENDAMENTO
            if (NovoEstado == "Aprovar")
            {
                agendamento.Evento.Status = (uint)StatusAgendamento.APROVADO;
            }
            else if (NovoEstado == "Reprovar")
            {
                agendamento.Evento.Status = (uint)StatusAgendamento.REPROVADO;
            }
            //Inserir(agendamento);
            //TODO PEGA A LINHA DO AGENDAMENTO
            var agendamentosTotais = ObterTodos();

            for (int i = 0; i < agendamentosTotais.Count; i++)
            {
                if (agendamentosTotais[i].Evento.Id == id)
                {
                    linha = i;
                    break;
                }
            }
            //TODO PEGA TODO O ARQUIVO
            var linhas = File.ReadAllLines(PATH);

            //TODO PEGA APENAS A LINHA QUE EU QUERO MUDAR E PREPARA UM REGISTRO CSV
            linhas[linha] = PrepararRegistroCSV(agendamento);
            //TODO MANDA DE VOLTA TODAS AS MUDANÇAS PRO CSV
            File.WriteAllLines(PATH, linhas);
        }
Пример #19
0
        public ActionResult SalvarAvaliacao(Avaliacao avaliacao)
        {
            //avaliacao.AvaliouSalao = true;


            //funcionario.RegistroFuncionarioAtivo = false;

            //db.Entry(agendamento).State = EntityState.Modified;
            //db.SaveChanges();


            if (ModelState.IsValid)
            {
                Agendamento agendamento = db.Agendamentos.Find(avaliacao.AgendamentoId);
                agendamento.AvaliouSalao    = true;
                db.Entry(agendamento).State = EntityState.Modified;
                db.SaveChanges();

                db.Avaliacoes.Add(avaliacao);
                db.SaveChanges();
                return(Content(JsonConvert.SerializeObject(new { id = avaliacao.Id })));
            }

            //ViewBag.ClienteId = avaliacao.Agendamento.ClienteId;
            // ViewBag.Avaliacoes = db.Funcionarios.Include(f => f.Cargo).ToList();

            return(View(avaliacao));
        }
Пример #20
0
        public bool Atualizar(Agendamento agendamento)
        {
            var agendamentosTotais = File.ReadAllLines(PATH);
            var agendamentoCSV     = PrepararRegistroCSV(agendamento);
            var linhaAgendamento   = -1;
            var resultado          = false;
            var id = agendamento.Evento.Id;

            for (int i = 0; i < agendamentosTotais.Length; i++)
            {
                var idConvertido = uint.Parse((ExtrairValorDoCampo("id", agendamentosTotais[i])));
                if (id.Equals(idConvertido))
                {
                    linhaAgendamento = i;
                    resultado        = true;
                    break;
                }
            }
            if (!resultado)
            {
                agendamentosTotais[linhaAgendamento] = agendamentoCSV;
                File.WriteAllLines(PATH, agendamentosTotais);
            }
            return(resultado);
        }
        static void Main(string[] args)
        {

            Agendamento agendamento = new Agendamento(123,new Paciente("123","Fabio"),new Atendente("1234","fabio")); 
            agendamento.AdicionarExame(new Exame());

        }
        public bool GerarArquivo(Agendamento agendamento, string id)
        {
            var caminhoDestino = ConfigurationManager.AppSettings["log_executados"];

            if (!Directory.Exists(caminhoDestino))
            {
                _notificationHandler.Handle(new Domain.Notificacoes.DomainNotification_("GeraLogTXT", "Diretório não existe"));
                return(false);
            }

            caminhoDestino = caminhoDestino + @"\" + agendamento.TSK + DateTime.Now.ToString("ddMMyyyyHHmmss") + extensao;

            try
            {
                using (StreamWriter sw = new StreamWriter(caminhoDestino, false, Encoding.UTF8))
                {
                    sw.WriteLine(id + "|" + DateTime.Now.ToString("yyyy-MM-dd"));
                    sw.Close();
                }
            }
            catch (Exception ex)
            {
                _notificationHandler.Handle(new Domain.Notificacoes.DomainNotification_("GeraLogTXT", ex.Message));
                return(false);
            }

            return(true);
        }
Пример #23
0
        public string ContratoAluguelPdf(Agendamento agendamento, Veiculo veiculo, string path)
        {
            var body = "<hr>";

            body += "<h3>Reserva</h3>";
            body += "<hr>";
            body += $"Data da reserva: {agendamento.DataAgendamento:dd/mm/yyyy HH:MM}<br>";
            body += $"Quantidade de horas alugadas: {agendamento.HorasLocacao}<br>";
            body += $"Data da coleta prevista: {agendamento.DataHoraColetaPrevista:dd/mm/yyyy HH:MM}<br>";
            body += $"Data de entrega prevista: {agendamento.DataHoraEntregaPrevista:dd/mm/yyyy HH:MM}<br>";
            body += $"Valor da hora: R${agendamento.ValorHora}";
            body += "<hr>";
            body += "<h3>Reserva do veículo</h3>";
            body += "<hr>";
            body += $"Placa: {veiculo.Placa}<br>";
            body += $"Marca: {veiculo.Marca.Nome}<br>";
            body += $"Modelo: {veiculo.Modelo.Nome}<br>";
            body += $"Categoria: {veiculo.Categoria.Nome}<br>";
            body += $"Capacidade do tanque: {veiculo.CapacidadeTanque}<br>";
            body += $"Capacidade do Porta Malas: {veiculo.CapacidadePortaMalas}";
            body += "<hr>";
            body += $"<h2>Valor Estimado: R${agendamento.SubTotal}</h2>";
            body += "<hr>";

            return(pdfWriter.Build(path, body));
        }
        public async Task EnviarAgendamento(Agendamento agendamento)
        {
            const string URL_POST_AGENDAMENTO = "https://aluracar.herokuapp.com/salvaragendamento";
            var          cliente = new HttpClient();

            var dataHoraAgendamento = new DateTime(
                agendamento.DataAgendamento.Year, agendamento.DataAgendamento.Month, agendamento.DataAgendamento.Day,
                agendamento.HoraAgendamento.Hours, agendamento.HoraAgendamento.Minutes, agendamento.HoraAgendamento.Seconds);

            var json = JsonConvert.SerializeObject(new
            {
                nome            = agendamento.Nome,
                fone            = agendamento.Fone,
                email           = agendamento.Email,
                carro           = agendamento.Modelo,
                preco           = agendamento.Preco,
                dataAgendamento = dataHoraAgendamento
            });

            var conteudo = new StringContent(json, Encoding.UTF8, "application/json");

            var resposta = await cliente.PostAsync(URL_POST_AGENDAMENTO, conteudo);

            agendamento.Confirmado = resposta.IsSuccessStatusCode;
            SalvaAgendamentoDb(agendamento);

            if (agendamento.Confirmado)
            {
                MessagingCenter.Send(agendamento, "SucessoAgendamento");
            }
            else
            {
                MessagingCenter.Send(new ArgumentException(), "FalhaAgendamento");
            }
        }
Пример #25
0
        public void Post([FromBody] Agendamento value)
        {
            var conexao = new Connection(new System.Data.SqlClient.SqlConnection());

            try
            {
                using (var repositorio = new AgendamentoRepositorio(new Connection(new System.Data.SqlClient.SqlConnection())))
                {
                    #region Validaçãoes
                    if (repositorio.Buscar(new Agendamento()
                    {
                        IdAgenda = value.IdAgenda
                    }).Where(x => x.Data == value.Data && x.Horario == value.Horario).Count() > 0)
                    {
                        throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.NotAcceptable)
                        {
                            Content      = new StringContent("Existe um outro agendamento para esse mesmo horário."),
                            ReasonPhrase = "Agendamento inválido"
                        });
                    }
                    #endregion


                    repositorio.Criar(value);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                conexao.Dispose();
            }
        }
Пример #26
0
        public ActionResult Form(int pacienteId, int agendamentoId)
        {
            AgendamentoDao ag          = new AgendamentoDao();
            Agendamento    agendamento = ag.BuscaPorId(agendamentoId);
            //Criando atendimento
            AtendimentosDao atend       = new AtendimentosDao();
            Atendimentos    atendimento = new Atendimentos();

            atendimento.data       = agendamento.data;
            atendimento.MedicoId   = agendamento.MedicoId;
            atendimento.PacienteId = agendamento.PacienteId;
            atendimento.Plano      = agendamento.Plano;

            atend.Cadastrar(atendimento);


            Prontuario    prontuario = new Prontuario();
            ProntuarioDao dao        = new ProntuarioDao();

            foreach (var item in dao.Select())
            {
                if (item.PacienteId == (pacienteId))
                {
                    prontuario = item;
                }
            }
            Componente_PacienteDao         com = new Componente_PacienteDao();
            HistoriaPatologicaPregressaDao h   = new HistoriaPatologicaPregressaDao();
            //ComponenteDao co = new ComponenteDao();
            PacienteDao paci     = new PacienteDao();
            Paciente    paciente = paci.BuscaPorId(pacienteId);

            HistoriaPatologicaPregressa historia = h.BuscaPorId(prontuario.HistoriaPatologicaPregressaId);
            //IList<Componente> lista_componente = new List<Componente>();
            IList <Componente_Paciente> lista = new List <Componente_Paciente>();

            if (com.BuscarAgendamentos(paciente.ID) != null)
            {
                lista = com.BuscarAgendamentos(paciente.ID);
                ViewBag.Componente = lista;
            }



            ConsultaDao      con            = new ConsultaDao();
            IList <Consulta> listaConsultas = con.BuscaPorPaciente(pacienteId);
            MedicoDao        me             = new MedicoDao();
            Medico           medico         = me.BuscaPorId(agendamento.MedicoId);



            ViewBag.Medico      = medico;
            ViewBag.Agendamento = agendamento;
            ViewBag.Consultas   = listaConsultas;
            ViewBag.Historia    = historia;
            ViewBag.Prontuario  = prontuario;
            ViewBag.Paciente    = paciente;

            return(View());
        }
Пример #27
0
        private void BtnFatura_Click(object sender, RoutedEventArgs e)
        {
            Faturamento f = new Faturamento();


            f.Tipo           = cbTipo.Text;
            f.DataConsulta   = dpDataConsulta.SelectedDate.Value;
            f.HorarioConsuta = tpHoraConsulta.Text;
            f.MedicoId       = Convert.ToInt32(cbCodigoMedico.SelectedValue);
            f.PessoaId       = Convert.ToInt32(cbCodigoPessoa.SelectedValue);
            f.PlanoId        = Convert.ToInt32(cbCodigoPlano.SelectedValue);
            f.Valor          = Convert.ToDecimal(tbValor.Text);
            f.TipoPagamento  = cbTipoPagamento.Text;
            f.Status         = "Faturado";

            using (DBContexto ctx = new DBContexto())
            {
                Agendamento a = ctx.Agendamentos.Find(Convert.ToInt32(tbCodigoAgendamento.Text));

                ctx.Agendamentos.Remove(a);
                ctx.Faturamentos.Add(f);
                ctx.SaveChanges();
            }
            this.Close();
        }
        public ActionResult Cadastrar(String nomePaciente, String nomeMedico, DateTime Data, String Hora, String Observacao, String Plano)
        {
            AgendamentoDao ag  = new AgendamentoDao();
            PacienteDao    dao = new PacienteDao();
            MedicoDao      me  = new MedicoDao();


            Agendamento agendamento = new Agendamento();

            agendamento.hora       = Hora;
            agendamento.data       = Data;
            agendamento.observacao = Observacao;
            agendamento.Plano      = Plano;
            foreach (var item in dao.Select())
            {
                if (item.Nome == nomePaciente)
                {
                    agendamento.PacienteId = item.ID;
                }
            }

            foreach (var item in me.Select())
            {
                if (item.nome == nomeMedico)
                {
                    agendamento.MedicoId = item.ID;
                }
            }

            string validacao = (ag.Cadastrar(agendamento) ? "Sim" : "Não");

            return(Json(validacao));
        }
Пример #29
0
        public async Task EnviarAgendamento(Agendamento pAgendamento)
        {
            HttpClient client = new HttpClient();

            var dataHoraAgendamento = new DateTime(pAgendamento.DataAgendamento.Year, pAgendamento.DataAgendamento.Month, pAgendamento.DataAgendamento.Day,
                                                   pAgendamento.HoraAgendamento.Hours, pAgendamento.HoraAgendamento.Minutes, pAgendamento.HoraAgendamento.Seconds);

            var json = JsonConvert.SerializeObject(new
            {
                nome            = pAgendamento.Nome,
                fone            = pAgendamento.Fone,
                email           = pAgendamento.Email,
                carro           = pAgendamento.Modelo,
                preco           = pAgendamento.Preco,
                dataAgendamento = dataHoraAgendamento
            });

            var conteudo = new StringContent(json, Encoding.UTF8, "application/json");

            var resposta = await client.PostAsync("https://aluracar.herokuapp.com/salvaragendamento", conteudo);

            pAgendamento.Confirmado = resposta.IsSuccessStatusCode;

            SalvarAgendamentoDB(pAgendamento);

            if (pAgendamento.Confirmado)
            {
                MessagingCenter.Send <Agendamento>(pAgendamento, "SucessoAgendamento");
            }
            else
            {
                MessagingCenter.Send <ArgumentException>(new ArgumentException(), "FalhaAgendamento");
            }
        }
        public void ObterConsultasCompletasComFiltroTest()
        {
            // given
            Paciente paciente1 = new Paciente(Guid.NewGuid(), "Joao", "", DateTime.Now, "M", "123.456.789-12", "12.123.456-1", "(21)98764-5433", "*****@*****.**", Guid.NewGuid());
            Medico   medico1   = new Medico(Guid.NewGuid(), "Marcos", "123.456.789-12", "12.345.678-1", 1214567, new DateTime(1980, 3, 6), "M", "(34)98543-3241", "*****@*****.**", Guid.NewGuid());
            Medico   medico2   = new Medico(Guid.NewGuid(), "Joana", "125.456.719-12", "11.345.678-9", 1233567, new DateTime(1980, 9, 1), "F", "(35)91543-3241", "*****@*****.**", Guid.NewGuid());

            Agendamento agendamento1 = new Agendamento(Guid.NewGuid(), DateTime.Now, DateTime.Now, "Nada", medico1, paciente1, null);
            Agendamento agendamento2 = new Agendamento(Guid.NewGuid(), DateTime.Now, DateTime.Now, "Nenhuma", medico2, paciente1, null);

            Consulta consulta1 = new Consulta(Guid.NewGuid(), DateTime.Now, "Dipirona", DateTime.MinValue.AddMinutes(15), agendamento1);
            Consulta consulta2 = new Consulta(Guid.NewGuid(), DateTime.Now, "Buscopan", DateTime.MinValue.AddMinutes(10), agendamento2);

            var listaConsultas = new List <Consulta>();

            listaConsultas.Add(consulta1);
            listaConsultas.Add(consulta2);

            this.consultaRepositoryMock.Setup(c => c.ObterConsultasCompletasComFiltro(It.IsAny <DateTime>(), It.IsAny <DateTime>(), paciente1.IdPaciente)).Returns(listaConsultas);

            var consultaService = new ConsultaService(this.consultaRepositoryMock.Object);

            // when
            var listaConsultasRetorno = new List <ConsultaListarViewModel>(consultaService.ObterConsultasCompletasComFiltro(DateTime.Now, DateTime.Now, paciente1.IdPaciente.ToString()));

            // then
            Assert.NotNull(listaConsultasRetorno);
            Assert.True(listaConsultas.Count == 2);
        }
        public async Task <IActionResult> Edit(int id, [Bind("AgendamentoID,PessoaID,PontoDeInteresseID,AData,AHora,ANumPessoas")] Agendamento agendamento)
        {
            if (id != agendamento.AgendamentoID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(agendamento);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AgendamentoExists(agendamento.AgendamentoID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PessoaID"]           = new SelectList(_context.Pessoa, "PessoaID", "PNome", agendamento.PessoaID);
            ViewData["PontoDeInteresseID"] = new SelectList(_context.PontoDeInteresse, "PontoDeInteresseID", "PNome", agendamento.PontoDeInteresseID);
            return(View(agendamento));
        }
   public bool Gravar(Agendamento agendamento)
   {
 
           _session.SaveOrUpdate(agendamento);
           _session.Flush();
     
       return true;
   }
        public virtual  Agendamento CadastrarAgendamento(Agendamento agendamento)
        {
            //Persistir na Base
            agendamento.Credencial = _servicoDeGeracaoCredencial.Gerar(agendamento.Paciente);
            

            //Disparar Eventos
            EventosDoDominio.Disparar(new AgendamentoCriado(agendamento));
            

            return agendamento;
        }
 public AgendamentoCriado(Agendamento agendamento)
 {
     Agendamento = agendamento;
 }
 public bool Gravar(Agendamento agendamento)
 {
     return true;
 }