public Car Add(Car car)
        {
            car.Id = _nextId;
            _carsDictionary.TryAdd(car.Id, car);
            _nextId++;

            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 }));

            return response;
        }
        public bool TryUpdate(Car car)
        {
            Car oldCar;
            if (_carsDictionary.TryGetValue(car.Id, out oldCar)) {

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

            return false;
        }
        public Car PutCar(int id, Car car)
        {
            car.Id = id;

            if (!_carsCtx.TryUpdate(car)) {

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

            return car;
        }
 public ActionResult Create(Car car)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             db.Cars.Add(car);
             db.SaveChanges();
             return RedirectToAction("Index");
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex);
     }
         return View(car);
 }
 // GET: Admin/Create
 public ActionResult Create()
 {
     Car car = new Car();
     return View(car);
 }