public CarClass Get(int id) { var carClassGet = CarClassFactoryDAL.GetCollectionDAL().Get(id); CarClass carClass = new CarClass(carClassGet.Id, carClassGet.Name); return(carClass); }
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 bool Create(CarClass carclass) { CarClassDTO carclassDTO = new CarClassDTO() { Id = 0, Name = carclass.Name, }; return(CarClassFactoryDAL.GetCollectionDAL().Create(carclassDTO)); }
public List <CarClass> GetAll() { List <CarClass> carClassList = new List <CarClass>(); var carClasses = CarClassFactoryDAL.GetCollectionDAL().GetAll(); foreach (var carclass in carClasses) { carClassList.Add(new CarClass(carclass.Id, carclass.Name)); } return(carClassList); }
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 bool Delete(int id) { return(CarClassFactoryDAL.GetCollectionDAL().Delete(id)); }