//public Car Post(Car car) { // if (null != car) { // car.Id = 1; // return car; // } // throw new HttpResponseException(new HttpResponseMessage() { // StatusCode = HttpStatusCode.BadRequest, // ReasonPhrase = "Car data must contain at least one value." // }); //} public Car Post(FormDataCollection carFormData) { var carFormKeyValues = carFormData.ReadAsNameValueCollection(); var car = new Car() { Make = carFormKeyValues["Make"], Model = carFormKeyValues["Model"], Price = Convert.ToSingle(carFormKeyValues["Price"]), Year = Convert.ToInt32(carFormKeyValues["Year"]) }; return car; }
public Car Put([FromUri]int id, Car car) { return car; }
private void writeItem(Car car, StreamWriter writer) { writer.WriteLine("{0},{1},{2},{3},{4}", Escape(car.Id), Escape(car.Make), Escape(car.Model), Escape(car.Year), Escape(car.Price)); }