/// <summary> /// Paging the specified passenger presenter. /// </summary> /// <param name="passengerPresenter">The passenger presenter.</param> /// <param name="pageNumber">The page number.</param> /// <param name="partialView">The partial view.</param> /// <param name="isExcept">if set to <c>true</c> [is except].</param> /// <param name="searchType">Type of the search.</param> /// <param name="option">The option.</param> /// <param name="isAll">The is all.</param> /// <returns> /// The Action Result. /// </returns> public async Task<ActionResult> Paging(PassengerPresenter passengerPresenter, string pageNumber, string partialView, bool isExcept, string searchType, string option, bool? isAll) { if (passengerPresenter != null && !string.IsNullOrEmpty(pageNumber) && !pageNumber.Equals(UndefinedConstant) && !string.IsNullOrEmpty(partialView)) { if (!string.IsNullOrEmpty(partialView) && string.Equals(partialView, SearchPassengerListPartialView, StringComparison.OrdinalIgnoreCase)) { var personsList = SessionData.Instance.PersonItemListResult.ToList(); var pagingResult = GetPagedResult(Convert.ToString(pageNumber), personsList); if (pagingResult != null && pagingResult.Count > 0) { var pagingListResult = new ListResult<Person>(); pagingListResult.AssignItems(pagingResult); pagingListResult.TotalResults = SessionData.Instance.TotalResults; passengerPresenter.AssignPersonSearchResult(pagingListResult); passengerPresenter.GuestTotalResults = SessionData.Instance.GuestTotal; passengerPresenter.CrewTotalResults = SessionData.Instance.CrewTotal; passengerPresenter.VisitorTotalResults = SessionData.Instance.VisitorTotal; passengerPresenter.IsMessage |= !string.IsNullOrEmpty(SessionData.Instance.IsMessageMode) && SessionData.Instance.IsMessageMode.Equals(TrueConstant, StringComparison.OrdinalIgnoreCase); if (!string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = option; } else if (string.IsNullOrEmpty(passengerPresenter.SelectedPassengerType) && string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = passengerPresenter.GuestTotalResults > 0 ? GuestConstant : passengerPresenter.CrewTotalResults > 0 ? CrewConstant : passengerPresenter.VisitorTotalResults > 0 ? VisitorConstant : string.Empty; } return this.PartialView(SearchPassengerListPartialView, passengerPresenter); } } else { if (string.IsNullOrEmpty(passengerPresenter.SelectedVoyage)) { foreach (var voyage in SessionData.Instance.MasterData.Voyages) { passengerPresenter.SelectedVoyage += voyage.VoyageId + CommaSeparator; } } var pagingPageNumber = Convert.ToInt32(pageNumber) > 0 ? Convert.ToInt32(pageNumber) / ApplicationSettings.MaxPageSize : 1; var persons = await this.personManager.GetPersonsAsync(this.SetSearchFilters(passengerPresenter, isExcept, searchType, pagingPageNumber, option, isAll), passengerPresenter.AuthenticationToken); passengerPresenter.GuestTotalResults = persons.GuestTotalResults; passengerPresenter.CrewTotalResults = persons.CrewTotalResults; passengerPresenter.VisitorTotalResults = persons.VisitorTotalResults; passengerPresenter.IsMessage |= !string.IsNullOrEmpty(SessionData.Instance.IsMessageMode) && SessionData.Instance.IsMessageMode.Equals(TrueConstant, StringComparison.OrdinalIgnoreCase); if (!string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = option; } else if (string.IsNullOrEmpty(passengerPresenter.SelectedPassengerType) && string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = passengerPresenter.GuestTotalResults > 0 ? GuestConstant : passengerPresenter.CrewTotalResults > 0 ? CrewConstant : passengerPresenter.VisitorTotalResults > 0 ? VisitorConstant : string.Empty; } SessionData.Instance.AssignPersonSearchResult(persons.Items.ToList()); passengerPresenter.AssignPersonSearchResult(persons); return this.PartialView(partialView, passengerPresenter); } } return this.PartialView(partialView, passengerPresenter); }
public async Task<ActionResult> SearchPassenger(PassengerPresenter passengerPresenter, bool isExcept, string searchType, bool passengerList, string option, bool? isAll) { ModelState.Clear(); if (string.IsNullOrEmpty(option)) { SessionData.Instance.SelectedPassengerIds.Clear(); } if (string.IsNullOrEmpty(passengerPresenter.SelectedVoyage)) { foreach (var voyage in SessionData.Instance.MasterData.Voyages) { passengerPresenter.SelectedVoyage += voyage.VoyageId + CommaSeparator; } } var partialView = PassengerListPartialView; if (passengerList) { partialView = SearchPassengerListPartialView; } var persons = new ListResult<Person>(); if (!string.IsNullOrEmpty(passengerPresenter.SelectedCitizenship)) { var selectedCitizenShip = passengerPresenter.SelectedCitizenship.Split(CommaSeparatorChar).ToList(); if ((!isExcept && selectedCitizenShip.Count != 0) || (isExcept && selectedCitizenShip.Count != 0 && selectedCitizenShip.Count < SessionData.Instance.MasterData.Countries.Count)) { if (passengerList) { persons = await this.personManager.GetPersonsAlertAndMessageAsync(this.SetSearchFilters(passengerPresenter, isExcept, searchType, 0, option, isAll)); SessionData.Instance.PersonItemListResult.Clear(); SessionData.Instance.GuestTotal = persons.GuestTotalResults; SessionData.Instance.CrewTotal = persons.CrewTotalResults; SessionData.Instance.VisitorTotal = persons.VisitorTotalResults; SessionData.Instance.TotalResults = persons.TotalResults; } else { persons = await this.personManager.GetPersonsAsync(this.SetSearchFilters(passengerPresenter, isExcept, searchType, 0, option, isAll), passengerPresenter.AuthenticationToken); } passengerPresenter.GuestTotalResults = persons.GuestTotalResults; passengerPresenter.CrewTotalResults = persons.CrewTotalResults; passengerPresenter.VisitorTotalResults = persons.VisitorTotalResults; SessionData.Instance.AssignPersonSearchResult(persons.Items.ToList()); var personList = new ListResult<Person>(); personList.AssignItems(persons.Items.Take(ApplicationSettings.MaxPageSize).ToList()); personList.GuestTotalResults = persons.GuestTotalResults; personList.CrewTotalResults = persons.CrewTotalResults; personList.VisitorTotalResults = persons.VisitorTotalResults; personList.TotalResults = persons.TotalResults; passengerPresenter.AssignPersonSearchResult(personList); } } if (!string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = option; } else if (string.IsNullOrEmpty(passengerPresenter.SelectedPassengerType) && string.IsNullOrEmpty(option)) { passengerPresenter.SelectedOptionType = passengerPresenter.GuestTotalResults > 0 ? GuestConstant : passengerPresenter.CrewTotalResults > 0 ? CrewConstant : passengerPresenter.VisitorTotalResults > 0 ? VisitorConstant : GuestConstant; } return this.PartialView(partialView, passengerPresenter); }