Beispiel #1
0
        public void Listar_Todos_Agenda()
        {
            var mockRepository = new Mock <IAgendaRepositorio>();
            var agendaServico  = new AgendaServico(mockRepository.Object);
            var obter          = agendaServico.ListarTodos();

            mockRepository.Verify(m => m.ListarTodos(), Times.Once());
        }
Beispiel #2
0
        public void Obter_Por_Id_Agenda()
        {
            var mockRepository = new Mock <IAgendaRepositorio>();
            var agendaServico  = new AgendaServico(mockRepository.Object);
            var obter          = agendaServico.ObterPorId(1);

            mockRepository.Verify(m => m.ObterPorId(It.IsAny <long>()), Times.Once());
        }
Beispiel #3
0
        public async Task <int> Insert(AgendaServico model)
        {
            using (IDbConnection conn = Connection)
            {
                string insertQuery = @"INSERT INTO [dbo].[AgendaServico]([IdBarbeiro], [IdServico], [IdCliente], [DataAgenda], [Horario]) VALUES (@IdBarbeiro, @IdServico, @IdCliente, @DataAgenda, @Horario)";

                var result = conn.Execute(insertQuery, model);
                return(result);
            }
        }
Beispiel #4
0
        public List <AgendaServico> BuscaAgendaServico(List <Object> Filtro)
        {
            List <AgendaServico> listAgendaServico = new List <AgendaServico>();

            #region SQL

            string comandoSQL = @" SELECT AgendaServico.* , SERVICO.DESCRICAO, servico.url_img 
                                        FROM AgendaServico, SERVICO 
                                WHERE AGENDASERVICO.IDSERVICO = SERVICO.ID ";

            if (Filtro != null)
            {
                for (int i = 0; i < Filtro.Count; i++)
                {
                    comandoSQL = comandoSQL + " " + Filtro.ElementAt(i);
                }
            }

            #endregion

            MySqlCommand cmd = new MySqlCommand(comandoSQL);
            cmd.Connection = conn.ConexaoMySql;
            MySqlDataReader sqlData = conn.ExecutarConsulta(cmd);

            using (sqlData)
            {
                try
                {
                    while (sqlData.Read())
                    {
                        AgendaServico AgendaServico = new AgendaServico();
                        AgendaServico.id = Convert.ToInt32(sqlData["ID"]);

                        AgendaServico.dthr_ini = Convert.ToDateTime(sqlData["dthr_ini"]);
                        AgendaServico.dthr_fim = Convert.ToDateTime(sqlData["dthr_fim"]);

                        AgendaServico.servico           = new Servico();
                        AgendaServico.servico.id        = Convert.ToInt32(sqlData["IDSERVICO"]);
                        AgendaServico.servico.descricao = sqlData["descricao"].ToString();
                        AgendaServico.servico.url_img   = sqlData["url_img"].ToString();
                        listAgendaServico.Add(AgendaServico);
                    }
                }
                catch (Exception e)
                {
                    listAgendaServico.Clear();
                }
                finally
                {
                    conn.FechaConexao();
                }
            }

            return(listAgendaServico);
        }
Beispiel #5
0
        public void Deletar_Agenda()
        {
            var mockRepository = new Mock <IAgendaRepositorio>();
            var agendaServico  = new AgendaServico(mockRepository.Object);

            agendaServico.Deletar(new Agenda()
            {
                Id = 1, NomePaciente = "Myriana Almeida", DataNascimentoPaciente = DateTime.Parse("04/09/1987"), DataInicialConsulta = new DateTime(2020, 11, 01, 08, 00, 00), DataFimConsulta = new DateTime(2020, 11, 01, 08, 30, 00), Observacoes = ""
            });
            mockRepository.Verify(m => m.Deletar(It.IsAny <Agenda>()), Times.Once());
        }
        // [Authorize(Roles = "cliente")]
        public async Task <ActionResult <dynamic> > Agendar([FromBody] AgendaServico model)
        {
            var result = await _agendaRepo.Insert(model);

            if (result == 0)
            {
                return(NotFound(new { message = "Erro ao Cadastrar agendamento!." }));
            }

            return(new
            {
                sucesso = true
            });
        }
Beispiel #7
0
        public CustomActionResult <MessageItem> deleteagenda_servico(AgendaServico agendaservico)
        {
            MessageItem      m             = new MessageItem();
            AgendaServicoDAO agendaservDAO = new AgendaServicoDAO();

            if (!agendaservDAO.Delete(agendaservico))
            {
                m.Code = "500";
                return(GetResultBadRequest(m));
            }
            else
            {
                m.Code = "200";
                return(GetResultOK(m));
            }
        }
Beispiel #8
0
        public void UpDateOrcamento(AgendaServico NovoOrcamento)
        {
            String caminho = "SERVER=localhost;DATABASE=Gessoft;UID=root;PASSWORD=vegas;";

            try
            {
                conexao = new MySqlConnection(caminho);
                conexao.Open();
                String       inserir  = "update agendaservico set cdStatus = '" + NovoOrcamento.CdStatus + "' where cdOrcamento='" + NovoOrcamento.CdOrcamento + "';";
                MySqlCommand comandos = new MySqlCommand(inserir, conexao);
                comandos.ExecuteNonQuery();
                conexao.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro de comandos:" + ex.Message);
            }
        }
Beispiel #9
0
        public void NovoCadastroServico(AgendaServico NovoServico)
        {
            String caminho = "SERVER=localhost;DATABASE=Gessoft;UID=root;PASSWORD=vegas;";

            try
            {
                conexao = new MySqlConnection(caminho);
                conexao.Open();
                String       inserir  = "INSERT INTO agendaservico (cdservico, descricao, cdcliente, dia, mes, ano) values('" + NovoServico.CdServico + "', '" + NovoServico.Descricao + "','" + NovoServico.CodigoCliente + "','" + NovoServico.Dia + "','" + NovoServico.Mes + "','" + NovoServico.Ano + "');";
                MySqlCommand comandos = new MySqlCommand(inserir, conexao);
                comandos.ExecuteNonQuery();
                conexao.Close();
            }
            catch (Exception ex)
            {
                throw new Exception("Erro de comandos:" + ex.Message);
            }
        }
Beispiel #10
0
        public bool Inclui(AgendaServico AgendaServico)
        {
            bool ret = true;

            String cSQL = @" INSERT INTO AgendaServico (IDSERVICO, DTHR_INI, DTHR_FIM) ";

            cSQL = cSQL + @" VALUES (@IDSERVICO, @DTHR_INI, @DTHR_FIM)";

            MySqlCommand comando = new MySqlCommand();

            conn.ConexaoMySql.Open();
            comando.Connection = conn.ConexaoMySql;
            comando.Parameters.Clear();
            comando.CommandText = cSQL;

            //comando.Parameters.Add("ID", MySqlDbType.Decimal).Value = AgendaServico.id;
            comando.Parameters.Add("idservico", MySqlDbType.Decimal).Value = AgendaServico.servico.id;
            comando.Parameters.Add("dthr_ini", MySqlDbType.DateTime).Value = AgendaServico.dthr_ini;
            comando.Parameters.Add("dthr_fim", MySqlDbType.DateTime).Value = AgendaServico.dthr_fim;

            try
            {
                int rt = comando.ExecuteNonQuery();
                if (rt == -1)
                {
                    ret = false;
                }
            }
            catch (Exception e)
            {
                ret = false;
            }
            finally
            {
                conn.ConexaoMySql.Close();
            }

            return(ret);
        }
Beispiel #11
0
        public void ConsultaOrcamento(AgendaServico ConsultaServico)
        {
            String MyConString = "SERVER=localhost;DATABASE=Gessoft;UID=root;PASSWORD=vegas;";

            try
            {
                MySqlConnection connection = new MySqlConnection(MyConString);
                MySqlCommand    command    = connection.CreateCommand();
                MySqlDataReader Reader;
                command.CommandText = "select * from agendaservico where mes = '" + ConsultaServico.Mes + "' and ano = '" + ConsultaServico.Ano + "' and dia = '" + ConsultaServico.Dia + " and cdOrcamento <> 'null' ';";
                connection.Open();
                Reader = command.ExecuteReader();

                while (Reader.Read())
                {
                    ConsultaServico.CdOrcamento = (Reader.GetInt16("cdOrcamento")).ToString();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro de comandos:" + ex.Message);
            }
        }
Beispiel #12
0
        public bool Delete(AgendaServico AgendaServico)
        {
            bool ret = true;

            String cSQL = @" DELETE FROM AgendaServico";

            cSQL = cSQL + @" WHERE AgendaServico.ID = @ID";

            MySqlCommand comando = new MySqlCommand();

            conn.ConexaoMySql.Open();
            comando.Connection = conn.ConexaoMySql;
            comando.Parameters.Clear();
            comando.CommandText = cSQL;

            comando.Parameters.Add("id", MySqlDbType.Decimal).Value = AgendaServico.id;

            try
            {
                int rt = comando.ExecuteNonQuery();
                if (rt == -1)
                {
                    ret = false;
                }
            }
            catch (Exception e)
            {
                ret = false;
            }
            finally
            {
                conn.ConexaoMySql.Close();
            }

            return(ret);
        }
Beispiel #13
0
 public async Task AgendarServico(AgendaServico agendaServico)
 {
     _dbContext.Add(agendaServico);
     await _dbContext.SaveChangesAsync();
 }