public async Task <bool> UpdateReservation(Guid id, UpdateReservationDto model, string fields) { var reservation = await _service.Query(id, true); reservation.UpdateTime = DateTime.Now; return(await _service.Update(CommonClass.SetModelValue(model, reservation, fields))); }
public JsonResult UpdateReservation(UpdateReservationDto reservationToUpdate) { var supplier = _usersManagementService.GetActiveCustomer(HttpContext); var customerNo = supplier != null ? supplier.CustomerNo : string.Empty; var result = _bokaRepository.UpdateReservation(reservationToUpdate, customerNo); return(result == null?Json(new { updateReservations = string.Empty }) : Json(new { updateReservations = result.ToArray() })); }
public async Task UpdateReservation(Guid reference, UpdateReservationDto reservationDto) { Reservation reservation = await _context.Reservations.FirstOrDefaultAsync(e => e.Ref == reference); if (reservation == null) { throw new ReservationNotFoundException(reference); } if (reservationDto.DepartureDate.HasValue) { reservation.DepartureDate = reservationDto.DepartureDate.Value; } if (reservationDto.ArrivalDate.HasValue) { reservation.ArrivalDate = reservationDto.ArrivalDate.Value; } if (reservationDto.NumberOfAdults != null) { reservation.NumberOfAdults = reservationDto.NumberOfAdults.Value; } if (reservationDto.NumberOfChildren != null) { reservation.NumberOfChildren = reservationDto.NumberOfChildren.Value; } if (reservationDto.UserId != null) { reservation.UserId = reservationDto.UserId.Value; } _context.Update(reservation); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } }
public async Task <IActionResult> UpdateReservation([FromRoute] Guid id, [FromBody] UpdateReservationDto model, [FromQuery] string fields) { try { var result = await _manager.UpdateReservation(id, model, fields); if (!result) { return(Ok(new JsonMessageResult("Fail", 0, 0))); } return(NoContent()); } catch (Exception e) { _logger.LogError(e, e.Message); return(Ok(new JsonMessageResult(e.Message, 0, 0))); } }
public async Task <IActionResult> PutReservation([FromRoute] Guid reference, [FromBody] UpdateReservationDto reservationDto) { try { await _reservationService.UpdateReservation(reference, reservationDto); } catch (Exception e) { if (e is ReservationNotFoundException) { return(NotFound(e.Message)); } throw e; } return(NoContent()); }
public ActionResult <UpdateReservationDto> Update([FromBody] UpdateReservationDto reservationDto) { if (reservationDto == null) { return(NotFound("Empty object was sent.")); } var reservationFromDb = _reservationService.Get(reservationDto.Id); if (reservationFromDb == null) { return(NotFound("Reservation doesn't exist.")); } reservationFromDb.Name = reservationDto.Name; reservationFromDb.PhoneNumber = reservationDto.PhoneNumber; _reservationService.Update(reservationFromDb); return(Ok()); }
public IHttpActionResult UpdateReservation(UpdateReservationDto updateReservationDto) { var reservationInDb = _context.Reservations.Include(o => o.Book).SingleOrDefault(o => o.Id == updateReservationDto.ReservationId); if (reservationInDb == null) { return(NotFound()); } reservationInDb.ReservationStatusId = updateReservationDto.StatusId; //if the reservation is rejected, make book available again if (updateReservationDto.StatusId == REJECTED) { reservationInDb.Book.NumberAvailable++; } _context.SaveChanges(); return(Ok()); }
public void Put(int id, UpdateReservationDto value) { //if the bill is settled we can not not modified it }