public IHttpActionResult UpdateCarRentalPrice(int id, CarRentalDTO carRentalDto) { var rentalFromDb = _carRentalAppService.GetById(id); if (rentalFromDb == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } rentalFromDb.TotalPricePerDay = carRentalDto.TotalPricePerDay; rentalFromDb.RentedWithEnsurance = carRentalDto.RentedWithEnsurance; rentalFromDb.RentedWithNavigation = carRentalDto.RentedWithNavigation; _uow.Save(); return(Ok()); }
public IHttpActionResult AddCarRental(CarRentalDTO carRentalDto) { if (!ModelState.IsValid) { return(BadRequest()); } var carRental = Mapper.Map <CarRentalDTO, CarRental>(carRentalDto); _carRentalAppService.Add(carRental); _uow.Save(); carRentalDto.Id = carRental.Id; return(Created(new Uri(Request.RequestUri + "/" + carRental.Id), carRentalDto)); }