public Car Add(Car car) {

            car.Id = _nextId;
            _carsDictionary.TryAdd(car.Id, car);
            _nextId++;

            return car;
        }
        public bool TryUpdate(Car car) {

            Car oldCar;
            if (_carsDictionary.TryGetValue(car.Id, out oldCar)) {

                return _carsDictionary.TryUpdate(car.Id, car, oldCar);
            }

            return false;
        }
        public bool TryUpdate(int id, Car car) {

            var index = cars.FindIndex(x => x.Id == id);

            if (index > 0) {

                cars[index] = car;
                return true;
            }

            return false;
        }
        public void Add(Car car) {

            int maxId = 1;

            if (cars.Any()) {

                maxId = cars.Max(x => x.Id);
            }

            car.Id = maxId + 1;

            cars.Add(car);
        }
        public Car Put(int id, Car car) {

            if (!_carsContext.TryUpdate(id, car)) {

                var response = new HttpResponseMessage(HttpStatusCode.NotFound) {
                    Content = new StringContent("Car not found")
                };

                throw new HttpResponseException(response);
            }

            return car;
        }
        public Car PutCar(int id, Car car) {

            car.Id = id;

            if (!_carsCtx.TryUpdate(car)) {

                var response =
                    new HttpResponseMessage(HttpStatusCode.NotFound);
                throw new HttpResponseException(response);
            }

            return car;
        }
        public HttpResponseMessage PostCar(Car car) {

            var createdCar = _carsCtx.Add(car);
            var response = Request.CreateResponse(HttpStatusCode.Created, createdCar);
            response.Headers.Location = new Uri(
                Url.Link(
                    "DefaultHttpRoute", new {
                        id = createdCar.Id,
                        controller = "cars"
                    }));

            return response;
        }
        public void Delete(Car car) {

            cars.Remove(car);
        }
        public HttpResponseMessage Post(Car car) {

            _carsContext.Add(car);
            return new HttpResponseMessage(HttpStatusCode.Created);
        }