Exemplo n.º 1
0
        public Brand ConvertFromServiceBrand(ServiceBrand serviceBrand)
        {
            Brand brandToReturn = new Brand();

            brandToReturn.Name    = serviceBrand.Name;
            brandToReturn.BrandId = serviceBrand.BrandId;
            return(brandToReturn);
        }
Exemplo n.º 2
0
        public IEnumerable <ServiceBrand> GetAllBrands()
        {
            List <ServiceBrand> brands = new List <ServiceBrand>();

            using (SqlConnection connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                using (SqlCommand cmdGetAllBrands = connection.CreateCommand())
                {
                    cmdGetAllBrands.CommandText = "SELECT name, brandId FROM Brand";
                    SqlDataReader brandReader = cmdGetAllBrands.ExecuteReader();

                    while (brandReader.Read())
                    {
                        ServiceBrand brand = new ServiceBrand();
                        brand.Name    = brandReader.GetString(brandReader.GetOrdinal("name"));
                        brand.BrandId = brandReader.GetInt32(brandReader.GetOrdinal("brandId"));

                        brands.Add(brand);
                    }
                }
            }
            return(brands);
        }