示例#1
0
        public Anunciante getAnunciante(String Email)
        {
            string connectionString = "Server=DESKTOP-IO4T1DR\\SQLExpress; AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL11.SQLEXPRESS\\MSSQL\\DATA\\DivulgueAquiDB.mdf; Database=DivulgueAquiDB; Trusted_Connection = Yes;";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    string cmd = "SELECT * FROM Anunciante WHERE email=@Email";

                    SqlCommand command = new SqlCommand(cmd, connection);
                    command.Parameters.AddWithValue("@Email", Email);
                    command.Connection.Open();
                    var reader             = command.ExecuteReader();
                    Models.Anunciante anun = new Models.Anunciante();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            anun.NomeAnunciante = (string)reader["nomeAnunciante"];
                            anun.NomeComercio   = (string)reader["nomeComercio"];
                            anun.ValorPacote    = (float)reader["valorPacote"];
                            anun.Email          = (string)reader["email"];
                            anun.LatLong        = (string)reader["latLong "];
                        }
                    }
                    return(anun);
                }
                catch (Exception ex)
                {
                    throw new Exception("Erro: " + ex.Message);
                }
            }
        }
示例#2
0
        public List <Models.Anunciante> teste1()
        {
            List <Models.Anunciante> lista = new List <Models.Anunciante>();

            Models.Anunciante fiel = new Models.Anunciante();
            fiel.LatLong        = "(-12.96265216518016, -38.50096648473988)";
            fiel.Email          = "*****@*****.**";
            fiel.NomeAnunciante = "Adenilson";
            fiel.NomeComercio   = "mercadinho";
            lista.Add(fiel);


            Models.Anunciante fiel1 = new Models.Anunciante();
            fiel1.Email          = "*****@*****.**";
            fiel1.NomeAnunciante = "Abesvaldo";
            fiel1.NomeComercio   = "Churros";
            fiel.LatLong         = "(-13.0010719, -38.530658)";
            lista.Add(fiel1);

            Models.Anunciante fiel2 = new Models.Anunciante();
            fiel2.Email          = "*****@*****.**";
            fiel2.NomeAnunciante = "fulano";
            fiel2.NomeComercio   = "1,99";
            fiel.LatLong         = "(-12.986687, -38.4958537)";
            lista.Add(fiel2);

            return(lista);
        }
示例#3
0
        public List <Models.Anunciante> GetAnunciantes()
        {
            string connectionString = "Server=DESKTOP-IO4T1DR\\SQLExpress; AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL11.SQLEXPRESS\\MSSQL\\DATA\\DivulgueAquiDB.mdf; Database=DivulgueAquiDB; Trusted_Connection = Yes;";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    string cmd = "SELECT nomeAnunciante, nomeComercio, email, valorPacote FROM Anunciante";

                    SqlCommand command = new SqlCommand(cmd, connection);
                    command.Connection.Open();
                    var reader = command.ExecuteReader();
                    List <Models.Anunciante> lista = new List <Models.Anunciante>();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            Models.Anunciante anun = new Models.Anunciante();
                            anun.NomeAnunciante = (string)reader["nomeAnunciante"];
                            anun.NomeComercio   = (string)reader["nomeComercio"];
                            anun.Email          = (string)reader["email"];
                            anun.ValorPacote    = (double)reader["valorPacote"];
                            lista.Add(anun);
                        }
                        return(lista);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception("Erro: " + ex.Message);
                }
                return(null);
            }
        }
示例#4
0
        public ActionResult Detalhes(Anunciante a)
        {
            string connectionString = "Server=DESKTOP-IO4T1DR\\SQLExpress; AttachDbFilename=C:\\Program Files\\Microsoft SQL Server\\MSSQL11.SQLEXPRESS\\MSSQL\\DATA\\DivulgueAquiDB.mdf; Database=DivulgueAquiDB; Trusted_Connection = Yes;";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                try
                {
                    string cmd = "SELECT * FROM Anunciante WHERE Email=@Email";

                    SqlCommand command = new SqlCommand(cmd, connection);
                    command.Connection.Open();
                    var reader             = command.ExecuteReader();
                    Models.Anunciante anun = new Models.Anunciante();
                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            anun.NomeAnunciante = (string)reader["NomeAnunciante"];
                            anun.NomeComercio   = (string)reader["NomeComercio"];
                            anun.TipoComercio   = (string)reader["TipoComercio"];
                            anun.TipoPacote     = (string)reader["TipoPacote"];
                            anun.IdAnunciante   = (int)reader["IdAnunciante"];
                            anun.Email          = (string)reader["Email"];
                            anun.Location       = (string)reader["Location"];
                        }
                    }
                    return(View(anun));
                }
                catch (Exception ex)
                {
                    throw new Exception("Erro: " + ex.Message);
                }
            }
        }
示例#5
0
        public Anunciante teste()
        {
            List <Models.Anunciante> lista = new List <Models.Anunciante>();

            Models.Anunciante fiel = new Models.Anunciante();
            fiel.LatLong        = "(-13.0010719, -38.530658)";
            fiel.Email          = "*****@*****.**";
            fiel.NomeAnunciante = "Adenilson";
            fiel.NomeComercio   = "mercadinho";

            return(fiel);
        }
示例#6
0
        public List <Models.Anunciante> teste()
        {
            List <Models.Anunciante> lista = new List <Models.Anunciante>();

            Models.Anunciante fiel = new Models.Anunciante();
            fiel.Email          = "*****@*****.**";
            fiel.NomeAnunciante = "Adenilson";
            fiel.NomeComercio   = "mercadinho";
            fiel.TipoPacote     = "4 ANUNCIOS";

            Models.Anunciante fiel1 = new Models.Anunciante();
            fiel1.Email          = "*****@*****.**";
            fiel1.NomeAnunciante = "Abesvaldo";
            fiel1.NomeComercio   = "Churros";
            fiel1.TipoPacote     = "9 ANUNCIOS";
            lista.Add(fiel1);

            return(lista);
        }