Beispiel #1
0
        public List <Exterior> GetExteriors()
        {
            List <Exterior> _exteriors = new List <Exterior>();

            using (SqlConnection conn = new SqlConnection())
            {
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["CarDealership"].ConnectionString;
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = conn;
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "GetExterior";

                conn.Open();
                using (SqlDataReader dr = cmd.ExecuteReader())
                {
                    while (dr.Read())
                    {
                        Exterior currentRow = new Exterior();
                        currentRow.Color   = dr["ExteriorColor"].ToString();
                        currentRow.ColorId = (int)dr["ExteriorColorId"];
                        _exteriors.Add(currentRow);
                    }
                }
            }
            return(_exteriors);
        }
Beispiel #2
0
        public void ModifyExterior(Exterior baseClass)
        {
            Exterior exterior1 = (_ctx.BaseClasses.FirstOrDefault(e => e.Id == baseClass.Id) as Exterior);

            exterior1.Name        = (baseClass as Exterior).Name;
            exterior1.Price       = (baseClass as Exterior).Price;
            exterior1.TypeOfPaint = (baseClass as Exterior).TypeOfPaint;
            exterior1.Producer    = (baseClass as Exterior).Producer;
            _ctx.SaveChanges();
        }
Beispiel #3
0
        public void DefaultColorShouldBeUnknown()
        {
            // Arrange
            var exterior = new Exterior();

            // Act
            var color = exterior.Color;

            // Assert
            color.Should().Be(Colors.Unknown);
        }
Beispiel #4
0
        public void GetTheColor()
        {
            // Arrange
            var exterior = new Exterior(Colors.Unknown);

            // Act
            var color = exterior.Color;

            // Assert
            color.Should().Be(Colors.Unknown);
        }
Beispiel #5
0
 public ExteriorUI ConvertToExteriorUI(Exterior exterior)
 {
     return(new ExteriorUI
     {
         Id = exterior.Id,
         Colour = exterior.Colour,
         Name = exterior.Name,
         Price = exterior.Price,
         Producer = exterior.Producer,
         TypeOfPaint = exterior.TypeOfPaint
     });
 }
Beispiel #6
0
        public void Exteriors_WhenNotEqual_HashCodesNotEqual()
        {
            // Arrange
            var exterior1 = new Exterior();
            var exterior2 = new Exterior(Colors.Black);

            // Act
            var hashCodesEqual = exterior1.GetHashCode() == exterior2.GetHashCode();

            // Assert
            hashCodesEqual.Should().BeFalse();
        }
Beispiel #7
0
        public void Exteriors_AreNotEqual()
        {
            // Arrange
            var exterior1 = new Exterior();
            var exterior2 = new Exterior(Colors.Black);

            // Act
            var areEqual = exterior1 == exterior2;

            // Assert
            areEqual.Should().BeFalse();
        }
Beispiel #8
0
        public void Exteriors_WhenEqual_HashCodesEqual()
        {
            // Arrange
            var exterior1 = new Exterior();
            var exterior2 = new Exterior();

            // Act
            var hashCodesEqual = exterior1.GetHashCode() == exterior2.GetHashCode();

            // Assert
            hashCodesEqual.Should().BeTrue();
        }
Beispiel #9
0
        public void Exteriors_AreEqual()
        {
            // Arrange
            var exterior1 = new Exterior();
            var exterior2 = new Exterior();

            // Act
            var areEqual = exterior1 == exterior2;

            // Assert
            areEqual.Should().BeTrue();
        }
Beispiel #10
0
        public Exterior ConvertTOExterior(ExteriorUI exteriorUI)
        {
            Exterior exterior = new Exterior()
            {
                Id          = exteriorUI.Id,
                Colour      = exteriorUI.Colour,
                Price       = exteriorUI.Price,
                Producer    = exteriorUI.Producer,
                TypeOfPaint = exteriorUI.TypeOfPaint
            };

            return(exterior);
        }
Beispiel #11
0
        public ExteriorDTO ConvertTOExteriorDTO(Exterior exterior)
        {
            ExteriorDTO exteriorDTO = new ExteriorDTO()
            {
                Id          = exterior.Id,
                Colour      = exterior.Colour,
                Price       = exterior.Price,
                Producer    = exterior.Producer,
                TypeOfPaint = exterior.TypeOfPaint
            };

            return(exteriorDTO);
        }
        protected override void Seed(Dealer context) // створення дефолтних класів з просеченими полями
        {
            User user = new User()
            {
                Login = "******", Password = "******", Ballance = 100000
            };

            context.Users.Add(user);

            Engine engine = new Engine {
                Cylinders = 6, HP = 218, Liters = 3, Name = "M57TU", Price = 2000, Producer = "BMW", Torque = 500, Type = "Diesel"
            };

            context.BaseClasses.Add(engine);

            Gearbox gearbox = new Gearbox {
                Name = "6HP26", Price = 1000, Producer = "ZF", Quantity = 6, Type = "Automatic"
            };

            context.BaseClasses.Add(gearbox);

            Interior interior = new Interior {
                Colour = "Black", Material = "Leather", Price = 1500, Producer = "BMW", Name = ""
            };

            context.BaseClasses.Add(interior);

            Exterior exterior = new Exterior {
                Colour = "Black", Name = "", Price = 1000, Producer = "BMW", TypeOfPaint = "Glossy"
            };

            context.BaseClasses.Add(exterior);

            Car car = new Car {
                Engine = engine, Exterior = exterior, Interior = interior, Name = "BMW X5", Price = 5000, Gearbox = gearbox, Status = "Not sold"
            };

            context.Cars.Add(car);

            context.SaveChanges();
        }
Beispiel #13
0
 private static Vehicle Create(
     VehicleId id,
     Vin vin,
     Year year,
     Make make,
     Model model,
     Trim trim,
     Exterior exterior,
     Interior interior,
     Price price,
     Odometer odometer)
 {
     return(Vehicle.Create(
                id,
                vin,
                year,
                make,
                model,
                trim,
                exterior,
                interior,
                price,
                odometer));
 }