private async Task ProcessReservationsAsync() { using var scope = _serviceScopeFactory.CreateScope(); _apaleoClient = scope.ServiceProvider.GetRequiredService <IApaleoClient>(); _reservationService = scope.ServiceProvider.GetRequiredService <IReservationService>(); var authenticatedClient = await _apaleoClient.AuthenticateClient(); var mostRecentReservationProcess = await _reservationService.GetMostRecentReservationProcess(); if (mostRecentReservationProcess >= DateTime.Now.AddDays(-1)) { return; } var recentReservations = (await _apaleoClient.GetReservationsFromDate(authenticatedClient, mostRecentReservationProcess)).ToList(); if (recentReservations.Any()) { await _apaleoClient.AddFoliosToReservations(authenticatedClient, recentReservations); await _reservationService.AddReservations(recentReservations); } }
public ReservationRepository(ApplicationDbContext applicationDbContext, IApaleoClient apaleoClient) : base(applicationDbContext) { _apaleoClient = apaleoClient; }