public async Task <Reservation> UpdateReservation(int id, UpdateReservationModel updatedReservation) { var reservation = await _reservationRepository.GetById(id); if (reservation == null) { throw new NotFoundException("A reservation with such Id was not found!"); } if (updatedReservation.StartDate.HasValue) { reservation.StartDate = updatedReservation.StartDate.Value; } if (updatedReservation.EndDate.HasValue) { reservation.EndDate = updatedReservation.EndDate.Value; } if (!await IsReservationIntervalValid(reservation)) { throw new InvalidInputException("Date interval is not valid!"); } _reservationRepository.Update(reservation); await _reservationRepository.SaveAll(); return(reservation); }
public async Task <IActionResult> UpdateReservation(int id, [FromBody] UpdateReservationModel updatedReservation) { var reservation = await _reservationService.UpdateReservation(id, updatedReservation); var mappedReservation = _mapper.Map <ReservationModel>(reservation); return(Ok(mappedReservation)); }
public virtual async Task <ActionResult <int> > UpdateReservation(UpdateReservationModel item) { var updateItemId = await _reservationService.UpsertAsync(item); return(Ok(updateItemId)); }
public async Task <IEnumerable <ReservationItem> > UpsertAsync(UpdateReservationModel item) { var reservation = _mapper.Map <ReservationItem>(item); return(await _reservationDataService.UpsertAsync(reservation)); }