Beispiel #1
0
        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 }));
        }
Beispiel #2
0
 public IList <CarDto> GetCustomerCars([FromUri] int customerId = 0)
 {
     using (var carsAccess = new CarsAccess())
         return(Mapper.Map <IList <CarDto> >(carsAccess.GetCustomerCars(customerId).ToList()));
 }