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)); }
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); }
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); }
public BrandCollection() { this.brandCollectionDAL = BrandFactoryDAL.GetCollectionDAL(); }