Exemplo n.º 1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionadoReenvio",
                                                    async(agendamento) =>
            {
                if (!agendamento.Confirmado)
                {
                    var reenviar = await DisplayAlert("Reenviar", "Deseja Reenviar o agendamento?", "Sim", "Não");
                    if (reenviar)
                    {
                        AgendamentoService agendamentoService = new AgendamentoService();
                        await agendamentoService.EnviarAgendamento(agendamento);
                        this.viewModel.AtualizarLista();
                    }
                }
            });

            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reeenviar", "Reenvio bem sucedido", "Ok");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Falha no Reenvio", "Ok");
            });
        }
Exemplo n.º 2
0
        private void AssinarMenssagens()
        {
            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionado",
                                                    async(agendamento) =>
            {
                if (!agendamento.Confirmado)
                {
                    var reeviar = await DisplayAlert("Reenviar", "Deseja reeinviar o agendamento?", "Sim", "Não");
                    if (reeviar)
                    {
                        AgendamentoService agendamentoService = new AgendamentoService();
                        await agendamentoService.EnviarAgendamento(agendamento);
                        this._viewModel.AtualizarLista();
                    }
                }
            });

            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reeinviar", "Reenvio com sucesso!", "Ok");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaoAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Falha", "Falha ao reenviar!", "Ok");
            });
        }
Exemplo n.º 3
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionado",
                                                    async(agendamento) =>
            {
                if (!agendamento.Confirmado)
                {
                    var reenviar = await DisplayAlert("Reenviar Agendamento", "Deseja reenviar o agendamento?", "Sim", "Não");

                    if (reenviar)
                    {
                        AgendamentoService agendamentoService = new AgendamentoService();
                        await agendamentoService.EnviarAgendamento(agendamento);
                        this._viewModel.AtualizarLista();
                    }
                }
            });

            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento",
                                                    async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Reenvio feito com sucesso!", "OK");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaAgendamento",
                                                    async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Erro ao reenviar agendamento, por favor tente mais tarde!", "OK");
            });
        }
Exemplo n.º 4
0
        /// <summary>
        /// Carrega os services para manipular os dados no banco de dados.
        /// </summary>
        static void carregaServices()
        {
            string ConnectionString_Desenvolvimento = "mongodb://127.0.0.1:27017/?readPreference=primary&ssl=false";

            agendamentodb = new AgendamentoService(new DatabaseSettings()
            {
                DatabaseName     = "agendamento",
                ConnectionString = ConnectionString_Desenvolvimento,
                Agendamento      = "agendamento"
            });

            reservadb = new ReservaService(new DatabaseSettings()
            {
                DatabaseName     = "agendamento",
                ConnectionString = ConnectionString_Desenvolvimento,
                Reserva          = "reserva"
            });

            horariodb = new HorarioService(new DatabaseSettings()
            {
                DatabaseName     = "agendamento",
                ConnectionString = ConnectionString_Desenvolvimento,
                Horario          = "horario"
            });
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionado", async(agendamento) =>
            {
                if (agendamento.Confirmado)
                {
                    return;
                }

                var reenviar = await DisplayAlert("Reenviar", "Deseja reenviar o agendamento?", "sim", "não");

                if (reenviar)
                {
                    AgendamentoService agendamentoService = new AgendamentoService();
                    await agendamentoService.EnviarAgendamento(agendamento);
                    this._viewModel.AtualizarLista();
                }
            });

            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Reenvio com sucesso!", "ok");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Falha ao reenviar!", "ok");
            });
        }
Exemplo n.º 6
0
        private void AssinaturaMensagens()
        {
            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionado", async(agendamento) =>
            {
                if (!agendamento.Confirmado)
                {
                    var reenviar = await DisplayAlert("Reenviar Agendamento", "Deseja reenviar o agendamento?", "SIM", "NÃO");

                    if (reenviar)
                    {
                        AgendamentoService agendamentoService = new AgendamentoService();
                        await agendamentoService.EnviarAgendamento(agendamento);
                        this._viewModel.AtualizarLista();
                    }
                }
            });

            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Reenvio realizado com sucesso.", "OK");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaAgendamento", async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Erro ao reenviar o agendamento. Tente novamente.", "OK");
            });
        }
Exemplo n.º 7
0
        public void BuscarAgendamentoPorDataAgendadaComIdMedico()
        {
            // given
            Paciente paciente1 = new Paciente(Guid.NewGuid(), "Joao", "", DateTime.Now, "M", "123.456.789-12", "12.123.456-1", "(21)98764-5433", "*****@*****.**", Guid.NewGuid());
            Paciente paciente2 = new Paciente(Guid.NewGuid(), "Joice", "", DateTime.Now, "F", "121.456.789-12", "15.123.456-1", "(21)98767-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());

            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", medico1, paciente2, null);


            var listaAgendamentos = new List <Agendamento>();

            listaAgendamentos.Add(agendamento1);
            listaAgendamentos.Add(agendamento2);

            this.agendamentoRepositoryMock.Setup(a => a.BuscarAgendamentoPorDataAgendadaComIdMedico(It.IsAny <DateTime>(), medico1.IdMedico)).Returns(listaAgendamentos);

            var agendamentoService = new AgendamentoService(this.agendamentoRepositoryMock.Object, this.consultaRepositoryMock.Object);

            // when
            var listaAgendamentosRetorno = new List <AgendamentoListarViewModel>(agendamentoService.BuscarAgendamentoPorDataAgendadaComIdMedico(DateTime.Now, medico1.IdMedico.ToString()));

            // then
            Assert.NotNull(listaAgendamentosRetorno);
            Assert.True(listaAgendamentosRetorno.Count == listaAgendamentos.Count);
        }
Exemplo n.º 8
0
        public void Setup()
        {
            var config = new MapperConfiguration(cfg => cfg.AddProfile <MappingProfile>());

            _mapper = config.CreateMapper();
            _agendamentoRepository = new Mock <IAgendamentoRepository>();
            _servicoRepository     = new Mock <IServicoRepository>();

            _agendamentoService = new AgendamentoService(_agendamentoRepository.Object, _servicoRepository.Object, _mapper);
        }
Exemplo n.º 9
0
        public void When_RepositoryReturnsNull_Then_ResultNull()
        {
            var         repoMock = new Mock <IRepository <Agendamento> >();
            Agendamento expected = null;

            repoMock.Setup(x => x.Find(It.IsAny <Guid>())).Returns(expected);

            var mapper  = new MapperConfiguration(config => config.AddProfile <MappingProfiles>()).CreateMapper();
            var busMock = new Mock <IBus>();
            var service = new AgendamentoService(repoMock.Object, mapper, busMock.Object);

            var result = service.Get(Guid.NewGuid());

            Assert.IsNull(result);
        }
Exemplo n.º 10
0
        public void NaoDeletarAgendamentoComConsultaTest()
        {
            // given
            this.consultaRepositoryMock.Setup(c => c.BuscarConsultaPorIdAgendamento(It.IsAny <Guid>())).Returns(new Consulta());
            this.agendamentoRepositoryMock.Setup(a => a.BuscarAgendamentoPorId(It.IsAny <Guid>())).Returns(new Agendamento());
            this.agendamentoRepositoryMock.Setup(a => a.DeletarAgendamento(It.IsAny <Agendamento>())).Returns(true);

            var agendamentoService = new AgendamentoService(this.agendamentoRepositoryMock.Object, this.consultaRepositoryMock.Object);

            // when
            var resultado = agendamentoService.DeletarAgendamento(Guid.NewGuid().ToString());

            // then
            Assert.NotNull(resultado);
            Assert.True(resultado.Id == 0);
        }
Exemplo n.º 11
0
        public void AtualizarAgendamentoTest()
        {
            // given
            var agendamento = new AgendamentoComIdViewModel("418A3CF2-A78F-4AD2-84C6-712638AD048B", DateTime.Now, DateTime.Now, "Nada", "C62ACB1E-94E1-487F-0F68-08D79090D2CB", "16E16A8D-469F-4286-A470-08D78CC0F920");

            this.agendamentoRepositoryMock.Setup(a => a.BuscarAgendamentoEntreDataEHora(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(new List <Agendamento>());
            this.agendamentoRepositoryMock.Setup(a => a.AtualizarAgendamento(It.IsAny <Agendamento>())).Returns(true);

            var agendamentoService = new AgendamentoService(this.agendamentoRepositoryMock.Object, this.consultaRepositoryMock.Object);

            // when
            var resultado = agendamentoService.AtualizarAgendamento(agendamento);

            // then
            Assert.NotNull(resultado);
            Assert.True(resultado.Id == 1);
        }
Exemplo n.º 12
0
        public void NaoCadastrarAgendamentoDentroIntervaloMesmoPacienteTempoTest()
        {
            // given
            var agendamento = new AgendamentoCadastrarViewModel(DateTime.Now, DateTime.Now, "Nada", "C62ACB1E-94E1-487F-0F68-08D79090D2CB", "16E16A8D-469F-4286-A470-08D78CC0F920");
            var lista       = new List <Agendamento>();

            lista.Add(new Agendamento());

            this.agendamentoRepositoryMock.Setup(a => a.BuscarAgendamentoEntreDataEHora(agendamento.DataHoraAgendamento.Subtract(new TimeSpan(0, 14, 0)), agendamento.DataHoraAgendamento.Add(new TimeSpan(0, 14, 0)), new Guid("16E16A8D-469F-4286-A470-08D78CC0F920"), It.IsAny <Guid>())).Returns(lista);
            this.agendamentoRepositoryMock.Setup(a => a.CadastrarAgendamento(It.IsAny <Agendamento>())).Returns(true);

            var agendamentoService = new AgendamentoService(this.agendamentoRepositoryMock.Object, this.consultaRepositoryMock.Object);

            // when
            var resultado = agendamentoService.CadastrarAgendamento(agendamento);

            // then
            Assert.NotNull(resultado);
            Assert.True(resultado.Id == 0);
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            //<objeto que recebe a mensagem>
            //(instancia que está assinando)
            MessagingCenter.Subscribe <Agendamento>(this, "AgendamentoSelecionado", async(agendamento) =>
            {
                //Verifica se o agendamento não foi confirmado e então reenvia
                if (!agendamento.Confirmado)
                {
                    //Pedindo confirmação do usuario
                    var reenviar = await DisplayAlert("Reenviar", "Deseja reenviar o agendamento?", "sim", "não");

                    if (reenviar)
                    {
                        AgendamentoService agendamentoService = new AgendamentoService();
                        await agendamentoService.EnviarAgendamento(agendamento);

                        //assim que o agendamento for reenviado, a view será notificada e vai atualizar a lista da viewmodel
                        this._viewModel.AtualizarLista();
                    }
                }
            });

            //(Recebe uma instancia do agendamento)
            MessagingCenter.Subscribe <Agendamento>(this, "SucessoAgendamento",
                                                    async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Reenvio com sucesso", "ok");
            });

            MessagingCenter.Subscribe <Agendamento>(this, "FalhaAgendamento",
                                                    async(agendamento) =>
            {
                await DisplayAlert("Reenviar", "Falha ao reenviar!", "ok");
            });
        }
 public async void SalvaAgendamento()
 {
     AgendamentoService agendamentoService = new AgendamentoService();
     await agendamentoService.EnviarAgendamento(this.Agendamento);
 }
        private AgendamentoController CreateAgendamentoController()
        {
            var agendamentoService = new AgendamentoService(agendamentoRepositoryMock.Object);

            return(new AgendamentoController(agendamentoService));
        }
Exemplo n.º 16
0
 public void Inicializar()
 {
     _mockAgendamentoRepositorio = new Mock <IAgendamentoRepositorio>();
     _agendamentoService         = new AgendamentoService(_mockAgendamentoRepositorio.Object);
 }
Exemplo n.º 17
0
 public AgendamentoAppService(AgendamentoService agendamentoService)
     : base(agendamentoService)
 {
     _agendamentoService = agendamentoService;
 }
Exemplo n.º 18
0
 public HomeController(PessoaService pessoaService, AgendamentoService agendamentoService)
 {
     _pessoaService      = pessoaService;
     _agendamentoService = agendamentoService;
 }
Exemplo n.º 19
0
 public void TestSetup()
 {
     BaseSqlTeste.SeedDatabase();
     _agendamentoService = new AgendamentoService(_agendamentoRepositorio);
 }
Exemplo n.º 20
0
 public AgendamentoController(AgendamentoService agendamentoService, IMapper mapper)
 {
     _agendamentoService = agendamentoService;
     _mapper             = mapper;
 }
Exemplo n.º 21
0
 public AgendamentoController(AgendamentoService AgendamentoService)
 {
     _dbService = AgendamentoService;
 }