Beispiel #1
0
        public void DeleteModelCar(int id)
        {
            ModelsCar modelsCar =
                DB.ModelsCars.FirstOrDefault(m => m.Id == id);

            if (modelsCar == null)
            {
                return;
            }

            DB.ModelsCars.Remove(modelsCar);
            DB.SaveChanges();
        }
Beispiel #2
0
        //Car model managment logic
        public ModelCarModel AddModelCar(ModelCarModel modelCar)
        {
            ModelsCar car = new ModelsCar
            {
                Model          = modelCar.model,
                ManufacturerId = modelCar.manufacturerId,
                PricePerDay    = modelCar.pricePerDay,
                Photo          = modelCar.photo
            };

            DB.ModelsCars.Add(car);
            DB.SaveChanges();

            return(GetOneModelCar(car.Id));
        }
Beispiel #3
0
        public ModelCarModel UpdateModelCarPrice(ModelCarModel carModel)
        {
            ModelsCar car =
                DB.ModelsCars.Where(m => m.Id == carModel.id).SingleOrDefault();

            if (carModel == null)
            {
                return(null);
            }

            car.PricePerDay = carModel.pricePerDay;
            DB.SaveChanges();

            return(GetOneModelCar(car.Id));
        }