コード例 #1
0
ファイル: FuelCollection.cs プロジェクト: freaxy123/Carworld
        public Fuel Get(int id)
        {
            var  fuelGet = FuelFactoryDAL.GetCollectionDAL().Get(id);
            Fuel fuel    = new Fuel(fuelGet.Id, fuelGet.Name);

            return(fuel);
        }
コード例 #2
0
ファイル: Car.cs プロジェクト: freaxy123/Carworld
        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));
        }
コード例 #3
0
ファイル: FuelCollection.cs プロジェクト: freaxy123/Carworld
        public bool Create(Fuel fuel)
        {
            FuelDTO fuelDTO = new FuelDTO()
            {
                Id   = 0,
                Name = fuel.Name,
            };

            return(FuelFactoryDAL.GetCollectionDAL().Create(fuelDTO));
        }
コード例 #4
0
ファイル: FuelCollection.cs プロジェクト: freaxy123/Carworld
        public List <Fuel> GetAll()
        {
            List <Fuel> fuelList = new List <Fuel>();
            var         fuels    = FuelFactoryDAL.GetCollectionDAL().GetAll();

            foreach (var fuel in fuels)
            {
                fuelList.Add(new Fuel(fuel.Id, fuel.Name));
            }

            return(fuelList);
        }
コード例 #5
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);
        }
コード例 #6
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);
        }
コード例 #7
0
ファイル: FuelCollection.cs プロジェクト: freaxy123/Carworld
 public bool Delete(int id)
 {
     return(FuelFactoryDAL.GetCollectionDAL().Delete(id));
 }