public void DeleteModelCar(int id) { ModelsCar modelsCar = DB.ModelsCars.FirstOrDefault(m => m.Id == id); if (modelsCar == null) { return; } DB.ModelsCars.Remove(modelsCar); DB.SaveChanges(); }
//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)); }
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)); }