public HttpResponseMessage Post(Car car)
 {
     _repository.Add(car);
     var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.Created);
     httpResponseMessage.Headers.Location = new Uri(Request.RequestUri.ToString() + "/" + car.Id.ToString());
     return httpResponseMessage;
 }
 public void Add(Car car)
 {
     using (CarContext context = new CarContext())
     {
         context.Cars.Add(car);
         context.SaveChanges();
     }
 }
 public void Update(Car car)
 {
     using (CarContext context = new CarContext())
     {
         var cars = context.Cars.Where(item => item.Id == car.Id);
         int count = cars.Count();
         context.Cars.RemoveRange(cars);
         context.SaveChanges();
         context.Cars.Add(car);
         context.SaveChanges();
     }
 }
		public void Update(Car car)
		{
			_cars[car.Id] = car;
		}
		public void Add(Car car)
		{
			car.Id = _nextId++;
			_cars.Add(car.Id, car);
		}
Esempio n. 6
0
 public void Put(Car car)
 {
     _carRepository.Update(car);
 }