private async Task <Common.Models.Bookings.BookingOrder> Update(Common.Models.Bookings.BookingOrder bookingOrder) { var entry = _dbContext.BookingOrders.Update(bookingOrder); await _dbContext.SaveChangesAsync(); _dbContext.DetachEntry(entry.Entity); return(entry.Entity); }
private async Task <Common.Models.Bookings.BookingOrder> ChangeBookingStatus(Common.Models.Bookings.BookingOrder bookingOrder) { bookingOrder.Status = BookingStatuses.WaitingForCancellation; bookingOrder.Modified = _dateTimeProvider.UtcNow(); var entry = _dbContext.BookingOrders.Update(bookingOrder); await _dbContext.SaveChangesAsync(); _dbContext.DetachEntry(entry.Entity); return(entry.Entity); }
public EdoContracts.Accommodations.Booking Create(Common.Models.Bookings.BookingOrder bookingOrder) { var referenceCode = bookingOrder.ReferenceCode; var status = GetStatus(bookingOrder.Status); var availabilityRequest = bookingOrder.AvailabilityRequest.GetValue <EdoContracts.Accommodations.AvailabilityRequest>(); var availableRates = bookingOrder.AvailableRates.GetValue <AvailableRates>(); var bookingRequest = bookingOrder.BookingRequest.GetValue <EdoContracts.Accommodations.BookingRequest>(); var accommodationId = availableRates.AccommodationId.ToString(); var supplierReferenceCode = availableRates.Id.ToString(); var checkInDate = availabilityRequest.CheckInDate; var checkOutDate = availabilityRequest.CheckOutDate; var rooms = bookingRequest.Rooms; var updateMode = EdoContracts.Accommodations.Enums.BookingUpdateModes.Asynchronous; return(new EdoContracts.Accommodations.Booking(referenceCode, status, accommodationId, supplierReferenceCode, checkInDate, checkOutDate, rooms, updateMode)); }
private Task <Common.Models.Bookings.BookingOrder> SetStatus(Common.Models.Bookings.BookingOrder bookingOrder, BookingStatuses status) { bookingOrder.Modified = _dateTimeProvider.UtcNow(); bookingOrder.Status = status; return(Update(bookingOrder)); }
private Result CheckIfCancellationDateValid(Common.Models.Bookings.BookingOrder bookingOrder) => _dateTimeProvider.UtcToday() < bookingOrder.CheckInDate.Date ? Result.Success() : Result.Failure($"Can not cancel the booking order '{bookingOrder.ReferenceCode}' with check-in date in the past");