public IHttpActionResult AddCar(CarDto car, [FromUri] int customerId) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (customerId <= 0) { return(BadRequest(customerId.ToString())); } car.CustomerId = customerId; Car carDb = Mapper.Map <Car>(car); using (var carsAccess = new CarsAccess()) { carsAccess.AddCar(carDb); } return(Ok(new { id = carDb.Id })); }
public IList <CarDto> GetCustomerCars([FromUri] int customerId = 0) { using (var carsAccess = new CarsAccess()) return(Mapper.Map <IList <CarDto> >(carsAccess.GetCustomerCars(customerId).ToList())); }