Esempio n. 1
0
        public bool Update()
        {
            var brands     = BrandFactoryDAL.GetCollectionDAL().GetAll();
            var carClasses = CarClassFactoryDAL.GetCollectionDAL().GetAll();
            var fuels      = FuelFactoryDAL.GetCollectionDAL().GetAll();

            CarDTO carDTO = new CarDTO
            {
                Id              = this.Id,
                BrandId         = brands[brands.FindIndex(item => item.Name == this.Brand)].Id,
                Model           = this.Model,
                Year            = this.Year,
                Price           = this.Price,
                Horsepower      = this.Horsepower,
                Torque          = this.Torque,
                Acceleration    = this.Acceleration,
                Topspeed        = this.Topspeed,
                CarClassId      = carClasses[carClasses.FindIndex(item => item.Name == this.CarClass)].Id,
                FuelId          = fuels[fuels.FindIndex(item => item.Name == this.Fuel)].Id,
                FuelConsumption = this.FuelConsumption,
                MadeByUser      = this.MadeByUser
            };

            return(CarFactoryDAL.GetDAL().Update(carDTO));
        }
Esempio n. 2
0
        public Brand(int id, string name, string origin)
        {
            this.Id     = id;
            this.Name   = name;
            this.Origin = origin;

            brandDAL = BrandFactoryDAL.GetDAL();
        }
Esempio n. 3
0
        public Car Get(int id)
        {
            var brands     = BrandFactoryDAL.GetCollectionDAL().GetAll();
            var carClasses = CarClassFactoryDAL.GetCollectionDAL().GetAll();
            var fuels      = FuelFactoryDAL.GetCollectionDAL().GetAll();

            var getCar = CarFactoryDAL.GetCollectionDAL().Get(id);
            Car car    = new Car(getCar.Id, brands[brands.FindIndex(item => item.Id == getCar.BrandId)].Name, getCar.Model,
                                 getCar.Year, getCar.Price, getCar.Horsepower, getCar.Torque, getCar.Acceleration,
                                 getCar.Topspeed, carClasses[carClasses.FindIndex(item => item.Id == getCar.CarClassId)].Name, fuels[fuels.FindIndex(item => item.Id == getCar.FuelId)].Name,
                                 getCar.FuelConsumption, getCar.MadeByUser);

            return(car);
        }
Esempio n. 4
0
        public List <Car> GetAllSorted(string property)
        {
            List <Car> carList    = new List <Car>();
            var        brands     = BrandFactoryDAL.GetCollectionDAL().GetAll();
            var        cars       = CarFactoryDAL.GetCollectionDAL().GetAllSorted(property);
            var        carClasses = CarClassFactoryDAL.GetCollectionDAL().GetAll();
            var        fuels      = FuelFactoryDAL.GetCollectionDAL().GetAll();

            foreach (var car in cars)
            {
                carList.Add(new Car(car.Id, brands[brands.FindIndex(item => item.Id == car.BrandId)].Name, car.Model,
                                    car.Year, car.Price, car.Horsepower, car.Torque, car.Acceleration,
                                    car.Topspeed, carClasses[carClasses.FindIndex(item => item.Id == car.CarClassId)].Name, fuels[fuels.FindIndex(item => item.Id == car.FuelId)].Name,
                                    car.FuelConsumption, car.MadeByUser));
            }

            return(carList);
        }
Esempio n. 5
0
 public Brand()
 {
     brandDAL = BrandFactoryDAL.GetDAL();
 }
Esempio n. 6
0
 public BrandCollection()
 {
     this.brandCollectionDAL = BrandFactoryDAL.GetCollectionDAL();
 }