/// <summary> /// Maps the guests alerts. /// </summary> /// <param name="guests">The guests.</param> /// <param name="searchParameters">The search parameters.</param> /// <returns> /// Task instance /// </returns> private async Task<ICollection<Guest>> MapGuestAlerts(ICollection<Guest> guests, GuestSearchParameters searchParameters) { if (guests != null && guests.Count > 0) { var personSearchParameter = new PersonSearchParameter { ReservationNumbers = searchParameters.ReservationNumbers, VoyageIds = searchParameters.VoyageIds, MaxResults = searchParameters.MaxResults, PageNumber = searchParameters.PageNumber, OrderBy = searchParameters.OrderBy }; var personTypeList = await this.referenceDataRepository.RetrievePersonTypeListAsync(); var guestPersonType = personTypeList.Items.FirstOrDefault(a => a.Name.Equals(PersonTypes.Guest.ToString(), StringComparison.OrdinalIgnoreCase)); var personStatus = guestPersonType != null ? await this.RetrievePersonStatus(guests.RetrieveIds(a => a.GuestId), PersonStatusConstant, guestPersonType.PersonTypeId, personSearchParameter) : null; searchParameters.GuestIds = guests.RetrieveIds(a => a.GuestId); var staterooms = DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(searchParameters.ShipId); var guestReservationDetails = this.guestCruiseDetailManager.RetrieveReservation(personSearchParameter); await Task.WhenAll(staterooms, guestReservationDetails); var guestCollection = await this.guestCruiseDetailManager.MapGuestDetails(guests, personStatus, searchParameters.ShipId, guestPersonType != null ? guestPersonType.PersonTypeId : string.Empty, guestReservationDetails.Result, staterooms.Result); var personAlertClientRepository = DIContainer.Instance.Resolve<PersonAlertClientRepository>(); await personAlertClientRepository.RetrieveAlertTypes(); if (GlobalCachingProvider.Instance.FindKey(DataAccess.Entities.CacheKey.AlertTypes.ToString())) { var list = GlobalCachingProvider.Instance.GetItem(DataAccess.Entities.CacheKey.AlertTypes.ToString()) as ListResult<DataAccess.Entities.AlertType>; var messageList = await personAlertClientRepository.RetrieveMessageTypes(searchParameters.AlertMessageStartDate, searchParameters.AlertMessageEndDate); if (list != null || messageList != null) { var result = await GuestCruiseDetailManager.RetrievePersonAlertDetails(list, messageList, searchParameters.GuestIds, searchParameters.AlertMessageStartDate, searchParameters.AlertMessageEndDate); if (result.Item1.Items.Count > 0 || result.Item3.Items.Count > 0) { if (guestCollection != null && guestCollection.Count > 0) { lock (this.syncLock) { guestCollection.ForEach(guest => { PersonAlertMapper.MapGuests(guest, result.Item2, result.Item1, list); PersonMessagesMapper.MapGuests(guest, result.Item3, messageList); }); } } } } } } return guests; }