public async Task <Reservation> Edit(EditReservationModel reservation)
        {
            if (reservation == null)
            {
                return(null);
            }

            try
            {
                Reservation dbObject = await _reservationRepository.Get(reservation.ReservationId);

                if (dbObject == null)
                {
                    return(null);
                }
                dbObject.StatusId          = reservation.StatusId;
                dbObject.DateOfReservation = DateTime.Now;

                await _reservationRepository.Update(dbObject);

                _logger.LogInformation(string.Format("Reservation was updated. Reservation ID: {0}, Status ID: {1}", dbObject.ReservationId, dbObject.StatusId));
                return(dbObject);
            }
            catch
            {
                _logger.LogInformation(string.Format("Error: Reservation wasn't updated. Reservation ID: {0}", reservation.ReservationId));
                return(null);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(EditReservationModel reservation)
        {
            var dbObject = await _reservationService.Edit(reservation);

            if (dbObject == null)
            {
                return(NotFound());
            }
            return(Created("Updated", _mapper.Map <Reservation, SuccessfulReservationModel>(dbObject)));
        }