public PersonSearchParameter GetSearchParameters() { PersonSearchParameter xParameters = new PersonSearchParameter(); if (!string.IsNullOrWhiteSpace(Request.QueryString["FirstName"])) { xParameters.xFirstName = Request.QueryString["FirstName"].ToString(); txtFirstname.Text = xParameters.xFirstName; } if (!string.IsNullOrWhiteSpace(Request.QueryString["LastName"])) { xParameters.xLastName = Request.QueryString["LastName"].ToString(); txtLastName.Text = xParameters.xLastName; } if (!string.IsNullOrWhiteSpace(Request.QueryString["FatherName"])) { xParameters.xFatherName = Request.QueryString["FatherName"].ToString(); txtFatherName.Text = xParameters.xFatherName; } if (!string.IsNullOrWhiteSpace(Request.QueryString["NationalID"])) { xParameters.xNationalID = Request.QueryString["NationalID"].ToString(); txtNationalID.Text = xParameters.xNationalID; } if (!string.IsNullOrWhiteSpace(Request.QueryString["BirthCartPlace"])) { xParameters.xBirthCartPlace = Request.QueryString["BirthCartPlace"].ToString(); txtBirthPlace.Text = xParameters.xBirthCartPlace; } xParameters.xSortBy = "FirstName"; if (!string.IsNullOrWhiteSpace(Request.QueryString["SortBy"])) { xParameters.xSortBy = Request.QueryString["SortBy"]; drpSortBy.SelectedValue = xParameters.xSortBy; } xParameters.xSortType = "Des"; if (!string.IsNullOrWhiteSpace(Request.QueryString["SortType"])) { xParameters.xSortType = Request.QueryString["SortType"]; drpSortType.SelectedValue = xParameters.xSortType; } xParameters.xPage = 1; xParameters.xPageSize = drpPageSize.SelectedValue == "All" ? int.MaxValue : drpPageSize.SelectedValue.ToInt(); ComPager._PageSize = xParameters.xPageSize; ComPager._PagerSize = 10; if (Request.QueryString["Page"] != null) { xParameters.xPage = Request.QueryString["Page"].ToInt(); } return(xParameters); }
public async Task RetrievePersonsListAsyncTest() { try { this.SetupGetRequests(); PersonSearchParameter objParam = new PersonSearchParameter(); objParam.MaxResults = 50; objParam.PageNumber = 1; this.personsManager.Setup(mokeItem => mokeItem.RetrievePersonListAsync(It.IsNotNull<PersonSearchParameter>())).Returns(Task.FromResult(new ListResult<Person>())); var response = await this.personsController.Get(objParam); var result = await response.ExecuteAsync(new CancellationToken(false)); Assert.IsTrue(result.IsSuccessStatusCode); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); } finally { this.Dispose(); } }
/// <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; }
/// <summary> /// Retrieves the guest. /// </summary> /// <param name="searchParameter">The search parameter.</param> /// <returns> /// The guest Response /// </returns> private async Task<ICollection<Guest>> RetrieveGuest(PersonSearchParameter searchParameter) { var travelWithGuests = await this.personRepository.RetrieveGuest(searchParameter); return travelWithGuests.Items; }
/// <summary> /// Retrieves the reservation. /// </summary> /// <param name="searchParameters">The guest search parameters.</param> /// <returns> /// Return the task as instance. /// </returns> internal async Task<IDictionary<string, DataAccess.Entities.GuestReservationDetail>> RetrieveReservation(PersonSearchParameter searchParameters) { var guestReservationDetails = new Dictionary<string, DataAccess.Entities.GuestReservationDetail>(); var reservations = await DIContainer.Instance.Resolve<ReservationClientRepository>().RetrieveReservations(searchParameters); if (reservations.Items.Count > 0) { guestReservationDetails = this.MapGuestReservationDetailsDictionary(reservations); } return guestReservationDetails; }
/// <summary> /// Retrieves the guests list. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <param name="isAlertCount">if set to <c>true</c> [is alert count].</param> /// <param name="guestIds">The guest ids.</param> /// <returns>The guest list.</returns> private async Task<ListResult<Person>> RetrieveGuestsList(PersonSearchParameter personSearchParameter, bool isAlertCount, List<string> guestIds) { ListResult<Person> personList = new ListResult<Person>(); if (guestIds.Count == 0 || !string.IsNullOrWhiteSpace(personSearchParameter.Birthdate)) { return personList; } ListResult<Stateroom> staterooms = new ListResult<Stateroom>(); var guests = await this.guestRepository.RetrieveGuests(personSearchParameter.LastNameContains, null, personSearchParameter.VoyageId, personSearchParameter.ReservationNo, personSearchParameter.PassportNo, personSearchParameter.Citizenship, guestIds.RetrieveIds(id => id), 1, int.MaxValue); if (string.IsNullOrWhiteSpace(personSearchParameter.Stateroom)) { var guestStateroomIds = guests.Items.RetrieveIds(a => a.ReservationDetail.StateroomId); if (!string.IsNullOrWhiteSpace(guestStateroomIds)) { staterooms = await this.RetrieveStaterooms(guestStateroomIds.TrimEnd(','), null); } } PersonMapper.MapPersonsByGuests(guests, staterooms, personList); var alerts = await this.RetrievePersonAlerts(personSearchParameter, personList.Items.RetrieveIds(p => p.PersonId)); PersonMapper.MapPersonAlerts(alerts, personList); personList.AssignItems(personList.Items.Where(item => isAlertCount ? item.AlertCount > 0 : item.MessageCount > 0).ToList()); personList.TotalResults = personList.Items.Count; personList.GuestTotalResults = personList.Items.Count; return personList; }
/// <summary> /// Retrieves the visitor lists. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <param name="visitorIds">The visitor ids.</param> /// <param name="isAlertCount">if set to <c>true</c> [is alert count].</param> /// <returns>The visitors list.</returns> private async Task<ListResult<Person>> RetrieveVisitorLists(PersonSearchParameter personSearchParameter, List<string> visitorIds, bool isAlertCount) { ListResult<Person> personList = new ListResult<Person>(); if (visitorIds.Count == 0 || !string.IsNullOrWhiteSpace(personSearchParameter.Stateroom) || !string.IsNullOrWhiteSpace(personSearchParameter.ReservationNo)) { return personList; } var visitor = await this.visitorClientRepository.RetrieveVisitors(visitorIds.RetrieveIds(id => id), personSearchParameter.LastNameContains, personSearchParameter.Citizenship, personSearchParameter.Birthdate, personSearchParameter.PassportNo, null, null, null, null, null, 1, int.MaxValue, VisitorDepths.Visitor, null); PersonMapper.MapPersonsByVisitors(visitor, personList); var alerts = await this.RetrievePersonAlerts(personSearchParameter, personList.Items.RetrieveIds(p => p.PersonId)); PersonMapper.MapPersonAlerts(alerts, personList); personList.AssignItems(personList.Items.Where(item => isAlertCount ? item.AlertCount > 0 : item.MessageCount > 0).ToList()); personList.TotalResults = personList.Items.Count; personList.VisitorTotalResults = personList.Items.Count; return personList; }
public async Task RetrieveVisitorListAsyncTestMethod() { try { var searchFilter = new PersonSearchParameter { CrewmemberIds = string.Empty, GuestIds = string.Empty, NameContains = "abc", DocumentNo = string.Empty, DocumentTypeId = string.Empty, PersonType = PersonTypes.Visitor, ReservationNumbers = string.Empty, Staterooms = string.Empty, VisitorIds = VisitorId, AlertMessageStartDate = DateTime.Now.ToString(), AlertMessageEndDate = DateTime.Now.ToString(), StartDate = DateTime.Now.ToString(), EndDate = DateTime.Now.ToString(), PageNumber = 1, MaxResults = 20 }; CommonDependencies(); this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); this.SetupVisitorDepartmentListAsync(); this.SetupVisitorVisitPurposeListAsync(); this.SetupRetrieveVisitTypeListAsync(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.IsTrue(result.Items.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Visitors.Count > 0); Assert.AreEqual("22", result.Items.FirstOrDefault().Visitors.FirstOrDefault().VisitorId); Assert.IsNotNull(result.Items.FirstOrDefault().Visitors.FirstOrDefault().PersonalDetail); } finally { this.Dispose(); } }
public async Task RetrieveGuestListByReservationNumberAsyncTestMethod() { try { var searchFilter = new PersonSearchParameter { ReservationNumbers = "111", AlertMessageStartDate = DateTime.Now.ToString(), AlertMessageEndDate = DateTime.Now.ToString(), PersonType = PersonTypes.Guest, ShipId = "5", PageNumber = 1, MaxResults = 5 }; this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); CommonDependencies(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); } finally { this.Dispose(); } }
/// <summary> /// Retrieves the visitor asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personTypeList">The person type list.</param> /// <returns> /// Return Nothing /// </returns> private async Task<ListResult<Visitor>> RetrieveVisitorsAsync(PersonSearchParameter searchParameters, ListResult<PersonTypeEntity> personTypeList) { var visitorList = new ListResult<Visitor>(); var visitors = await this.personRepository.RetrieveVisitor(searchParameters); var personTypeId = personTypeList.Items.FirstOrDefault(a => a.Name.Equals(PersonTypes.Visitor.ToString(), StringComparison.OrdinalIgnoreCase)); if (visitors != null && visitors.Items.Count > 0) { var personstatus = personTypeId != null ? await this.RetrievePersonStatus(visitors.Items.RetrieveIds(a => a.VisitorId), PersonStatusConstant, personTypeId.PersonTypeId, searchParameters, 1, 0) : null; //// For Retrieve Visitor Department on the basis of visitor ids. var deparmentIds = visitors.Items.Count > 0 ? visitors.Items.RetrieveIds(a => a.PersonalDetail.DepartmentId) : null; var departments = deparmentIds != null ? this.personRepository.RetrieveDepartmentListAsync(deparmentIds) : null; ////var visitPurposeIds = visitors.Items.Count > 0 ? visitors.Items.RetrieveIds(a => a.VisitPurpose) : null; var visitPurposeList = this.personRepository.RetrieveVisitPurposeListAsync(); var visitTypeList = this.personRepository.RetrieveVisitorTypeListAsync(); await Task.WhenAll(visitPurposeList, visitTypeList, departments); if (visitors.Items.Count > 0) { var mappedVisitoList = MapVisitorDetail(visitors.Items, personstatus, departments.Result != null ? departments.Result.Items : null, visitPurposeList.Result != null ? visitPurposeList.Result.Items : null, visitTypeList.Result != null ? visitTypeList.Result.Items : null); if (mappedVisitoList != null) { visitorList.TotalResults = visitors.TotalResults; visitorList.AssignItems(mappedVisitoList); } } } return visitorList; }
/// <summary> /// Retrieves the crew by name asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personTypeList">The person type list.</param> /// <returns> /// Return Nothing /// </returns> private async Task<ListResult<Crewmember>> RetrieveCrewByNameAsync(PersonSearchParameter searchParameters, ListResult<PersonTypeEntity> personTypeList) { var personSearchParameter = new PersonSearchParameter { NameContains = searchParameters.NameContains, StartDate = searchParameters.StartDate, EndDate = searchParameters.EndDate, PageNumber = searchParameters.PageNumber, MaxResults = searchParameters.MaxResults }; var crewmembers = await this.personRepository.RetrieveCrew(personSearchParameter); var personTypeId = personTypeList.Items.FirstOrDefault(a => a.Name.Equals(PersonTypes.Crew.ToString(), StringComparison.OrdinalIgnoreCase)); if (crewmembers != null && crewmembers.Items.Count > 0) { var personstatus = personTypeId != null ? await this.RetrievePersonStatus(crewmembers.Items.RetrieveIds(a => a.CrewmemberId), PersonStatusConstant, personTypeId.PersonTypeId, searchParameters, 1, 0) : null; return await this.MapCrewmemberStateroom(searchParameters.ShipId, crewmembers, personstatus); } return new ListResult<Crewmember>(); }
/// <summary> /// Searches the name of the by. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personType">Type of the person.</param> /// <returns> /// Return list result of person. /// </returns> private async Task<ListResult<Person>> SearchByName(PersonSearchParameter searchParameters, PersonTypes personType) { var personList = new ListResult<Person>(); var person = new Person(); var personTypeList = await this.referenceDataRepository.RetrievePersonTypeListAsync(); if ((personType & PersonTypes.All) == PersonTypes.All) { var staterooms = await DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(searchParameters.ShipId); var crewMemberList = this.RetrieveCrewByNameAsync(searchParameters, personTypeList); var visitorList = this.RetrieveVisitorsAsync(searchParameters, personTypeList); var guestList = this.RetrieveGuests(searchParameters, staterooms, false); await Task.WhenAll(guestList, crewMemberList, visitorList); AddCrewmembersInPerson(personList, person, crewMemberList.Result); AddVisitorInPerson(personList, person, visitorList.Result); AddGuestsInPerson(personList, person, guestList.Result); } else if (personType == PersonTypes.Crew) { var crewMemberList = await this.RetrieveCrewByNameAsync(searchParameters, personTypeList); AddCrewmembersInPerson(personList, person, crewMemberList); } else if (personType == PersonTypes.Visitor) { var visitorList = await this.RetrieveVisitorsAsync(searchParameters, personTypeList); AddVisitorInPerson(personList, person, visitorList); } else if (personType == PersonTypes.Guest) { var staterooms = await DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(searchParameters.ShipId); var guestList = await this.RetrieveGuests(searchParameters, staterooms, false); AddGuestsInPerson(personList, person, guestList); } personList.Items.Add(person); if (personList.Items.Count > 0) { await MapPersonAlerts(personList.Items.FirstOrDefault(), searchParameters.AlertMessageStartDate, searchParameters.AlertMessageEndDate); } return personList; }
/// <summary> /// Retrieves the stateroom ids. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="stateroomIds">The stateroom ids.</param> /// <param name="staterooms">The staterooms.</param> /// <returns>return string value.</returns> private static string RetrieveStateroomIds(PersonSearchParameter searchParameters, string stateroomIds, ListResult<DataAccess.Entities.Stateroom> staterooms) { var stateroomNumber = searchParameters.Staterooms.Split(CommaSeparatorCharacter); var ids = stateroomIds; stateroomNumber.ForEach(number => { var stateroom = staterooms.Items.FirstOrDefault(a => a.StateroomNumber.Equals(number, StringComparison.OrdinalIgnoreCase)); if (stateroom != null) { ids += stateroom.StateroomId + CommaSeparator; } }); return ids != null ? ids.Trim(CommaSeparatorCharacter) : null; }
/// <summary> /// Lists the asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns> /// Return List Result of person /// </returns> public async Task<ListResult<Person>> ListAsync(PersonSearchParameter searchParameters) { if (!string.IsNullOrWhiteSpace(searchParameters.NameContains) || !string.IsNullOrWhiteSpace(searchParameters.LastNameContains)) { /* Search a person by Name*/ return await this.SearchByName(searchParameters, searchParameters.PersonType.HasValue ? searchParameters.PersonType.Value : PersonTypes.All); } var person = await this.SearchOnPersonType(searchParameters); if (person.TotalResults > 0) { /* Map Person Alerts */ await MapPersonAlerts(person.Items.FirstOrDefault(), searchParameters.AlertMessageStartDate, searchParameters.AlertMessageEndDate); } return person; }
/// <summary> /// Retrieves the crew members. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns>Return Crew member Collection instance</returns> public async Task<ListResult<Entities.Crewmember>> RetrieveCrewmembers(PersonSearchParameter searchParameters) { var task = await this.crewServiceClient.RetrieveCrewmemberListAsync(photographerOnly: false, crewmemberIds: searchParameters.CrewmemberIds, crewmemberNameContains: searchParameters.LastNameContains, embarkDate: searchParameters.StartDate, debarkDate: searchParameters.EndDate, name: searchParameters.NameContains, stateroomIds: searchParameters.StateroomIds, accessCardNumber: searchParameters.AccessCardNumber, documentTypeIds: searchParameters.DocumentTypeId, documentNumbers: searchParameters.DocumentNo, employeeNo: searchParameters.EmployeeNumber, parts: !string.IsNullOrEmpty(searchParameters.Parts) ? searchParameters.Parts : PartialParts, pageNumber: searchParameters.PageNumber, maxResults: searchParameters.MaxResults.RetrieveMaxResults()); return task != null ? JsonConvert.DeserializeObject<ListResult<Entities.Crewmember>>(task) : default(ListResult<Entities.Crewmember>); }
public List <Person> GetPerson(ref int xCount, PersonSearchParameter xParameter) { using (UnitOfWork uow = new UnitOfWork()) { #region Clean xParameter xParameter.xFirstName = xParameter.xFirstName.Trim().ToLower(); xParameter.xLastName = xParameter.xLastName.Trim().ToLower(); xParameter.xFatherName = xParameter.xFatherName.Trim().ToLower(); xParameter.xNationalID = xParameter.xNationalID.Trim().ToLower(); xParameter.xBirthCartPlace = xParameter.xBirthCartPlace.Trim().ToLower(); #endregion #region OrderBy Func <IQueryable <Person>, IOrderedQueryable <Person> > xOrderBy = p => p.OrderBy(x => x.xFirstName); if (xParameter.xSortBy == "FirstName" || string.IsNullOrEmpty(xParameter.xSortBy)) { if (xParameter.xSortType == "Des") { xOrderBy = p => p.OrderByDescending(x => x.xFirstName); } else { xOrderBy = p => p.OrderBy(x => x.xFirstName); } } else if (xParameter.xSortBy == "LastName") { if (xParameter.xSortType == "Des") { xOrderBy = p => p.OrderByDescending(x => x.xLastName); } else { xOrderBy = p => p.OrderBy(x => x.xLastName); } } else if (xParameter.xSortBy == "FatherName") { if (xParameter.xSortType == "Des") { xOrderBy = p => p.OrderByDescending(x => x.xFatherName); } else { xOrderBy = p => p.OrderBy(x => x.xFatherName); } } #endregion #region Filter Expression <Func <Person, bool> > xFilter = p => true; if (!string.IsNullOrEmpty(xParameter.xFirstName)) { xFilter = xFilter.And(p => p.xFirstName.Contains(xParameter.xFirstName)); } if (!string.IsNullOrEmpty(xParameter.xLastName)) { xFilter = xFilter.And(p => p.xLastName.Contains(xParameter.xLastName)); } if (!string.IsNullOrEmpty(xParameter.xFatherName)) { xFilter = xFilter.And(p => p.xLastName.Contains(xParameter.xFatherName)); } if (!string.IsNullOrEmpty(xParameter.xNationalID)) { xFilter = xFilter.And(p => p.xNationalID.Contains(xParameter.xNationalID)); } if (!string.IsNullOrEmpty(xParameter.xBirthCartPlace)) { xFilter = xFilter.And(p => p.xBirthCartPlace.Contains(xParameter.xBirthCartPlace)); } #endregion var xPlanList = uow.PersonRepository.Get(ref xCount, xFilter, xOrderBy, xParameter.xPage, xParameter.xPageSize); return(xPlanList.ToList()); } }
public async Task RetrieveVisitorByDocumentListAsyncTestMethod() { try { var searchFilter = new PersonSearchParameter { DocumentNo = "1", DocumentTypeId = "1", PersonType = PersonTypes.Visitor, ShipId = "5", StartDate = "2015-12-19", PageNumber = 1, MaxResults = 5 }; this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); this.SetupVisitorDepartmentListAsync(); this.SetupVisitorVisitPurposeListAsync(); this.SetupRetrieveVisitTypeListAsync(); CommonDependencies(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.IsTrue(result.Items.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Visitors.Count > 0); Assert.AreEqual("22", result.Items.FirstOrDefault().Visitors.FirstOrDefault().VisitorId); } finally { this.Dispose(); } }
/// <summary> /// Searches the type of the on person. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns> /// Return person instance. /// </returns> private async Task<ListResult<Person>> SearchOnPersonType(PersonSearchParameter searchParameters) { var personList = new ListResult<Person>(); var person = new Person(); var personSearchParameter = searchParameters; var personTypeList = this.referenceDataRepository.RetrievePersonTypeListAsync(); var staterooms = DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(personSearchParameter.ShipId); await Task.WhenAll(personTypeList, staterooms); if (!string.IsNullOrEmpty(personSearchParameter.AccessCardNumber) || !string.IsNullOrEmpty(personSearchParameter.SourceIds)) { /* Search persons by Access Card Number */ person = await this.SearchPerson(personSearchParameter, personTypeList.Result, staterooms.Result); } else if (!string.IsNullOrWhiteSpace(personSearchParameter.Staterooms) && personSearchParameter.PersonType != PersonTypes.Visitor) { /* Search persons by Stateroom number*/ personSearchParameter.StateroomIds = RetrieveStateroomIds(personSearchParameter, personSearchParameter.StateroomIds, staterooms.Result); person = await this.SearchGuestAndCrew(personSearchParameter, personTypeList.Result, staterooms.Result); } else if (!string.IsNullOrEmpty(personSearchParameter.ReservationNumbers) && (personSearchParameter.PersonType == PersonTypes.Guest || personSearchParameter.PersonType == PersonTypes.All)) { /* Search persons by Reservation Number*/ var guestList = await this.RetrieveGuests(personSearchParameter, staterooms.Result, true); person.AssignGuests(guestList.Items); person.TotalGuestsCount = guestList.Items.Count; } else if (!string.IsNullOrEmpty(personSearchParameter.GuestIds) || !string.IsNullOrEmpty(personSearchParameter.CrewmemberIds) || !string.IsNullOrEmpty(personSearchParameter.VisitorIds) || !string.IsNullOrWhiteSpace(personSearchParameter.EmployeeNumber) || !string.IsNullOrWhiteSpace(personSearchParameter.DocumentNo) || personSearchParameter.Birthdate.HasValue) { /* Search persons by person ids , employee Number, birth date and Document no.*/ person = await this.RetrievePersonByIdAndDocument(personSearchParameter, personTypeList.Result, staterooms.Result); } personList.Items.Add(person); personList.TotalResults = person.Guests.Count + person.Crewmembers.Count + person.Visitors.Count; return personList; }
public async Task RetrieveGuestListByStateroomAsyncTestMethod() { try { var searchFilter = new PersonSearchParameter { PersonType = PersonTypes.All, Staterooms = "21", AlertMessageStartDate = DateTime.Now.ToString(), AlertMessageEndDate = DateTime.Now.ToString(), ShipId = "5", PageNumber = 1, MaxResults = 5 }; this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); CommonDependencies(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.IsTrue(result.Items.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Guests.Count > 0); Assert.AreEqual("600001", result.Items.FirstOrDefault().Guests.FirstOrDefault().GuestId); } finally { this.Dispose(); } }
/// <summary> /// Retrieves the person by identifier. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personTypeList">The person type list.</param> /// <param name="staterooms">The staterooms.</param> /// <returns>Return Instance of person.</returns> private async Task<Person> RetrievePersonByIdAndDocument(PersonSearchParameter searchParameters, ListResult<PersonTypeEntity> personTypeList, ListResult<DataAccess.Entities.Stateroom> staterooms) { var person = new Person(); var applicationSetting = DIContainer.Instance.Resolve<IApplicationSetting>(); if ((!string.IsNullOrEmpty(searchParameters.GuestIds) && !string.IsNullOrEmpty(searchParameters.CrewmemberIds) && !string.IsNullOrEmpty(searchParameters.VisitorIds)) || (!string.IsNullOrWhiteSpace(searchParameters.DocumentNo) && searchParameters.DocumentTypeId.Equals(applicationSetting.DocumentTypeId) && searchParameters.PersonType == PersonTypes.All)) { person = await this.SearchPerson(searchParameters, personTypeList, staterooms); } else if (!string.IsNullOrEmpty(searchParameters.GuestIds) && !string.IsNullOrEmpty(searchParameters.CrewmemberIds)) { person = await this.SearchGuestAndCrew(searchParameters, personTypeList, staterooms); } else if (!string.IsNullOrEmpty(searchParameters.GuestIds) && !string.IsNullOrEmpty(searchParameters.VisitorIds)) { var guestList = this.RetrieveGuests(searchParameters, staterooms, true); var visitorList = this.RetrieveVisitorsAsync(searchParameters, personTypeList); await Task.WhenAll(guestList, visitorList); person.AssignGuests(guestList.Result.Items); person.TotalGuestsCount = guestList.Result.TotalResults; person.AssignVisitors(visitorList.Result.Items); person.TotalVisitorsCount = visitorList.Result.Items.Count; } else if (!string.IsNullOrEmpty(searchParameters.CrewmemberIds) && !string.IsNullOrEmpty(searchParameters.VisitorIds)) { var crewMemberList = this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); var visitorList = this.RetrieveVisitorsAsync(searchParameters, personTypeList); await Task.WhenAll(crewMemberList, visitorList); person.AssignCrewmembers(crewMemberList.Result.Items); person.TotalCrewmembersCount = crewMemberList.Result.TotalResults; person.AssignVisitors(visitorList.Result.Items); person.TotalVisitorsCount = visitorList.Result.Items.Count; } else if (!string.IsNullOrEmpty(searchParameters.GuestIds) || (!string.IsNullOrWhiteSpace(searchParameters.DocumentNo) && searchParameters.PersonType == PersonTypes.Guest)) { var guestList = await this.RetrieveGuests(searchParameters, staterooms, true); person.AssignGuests(guestList.Items); person.TotalGuestsCount = guestList.TotalResults; } else if (!string.IsNullOrEmpty(searchParameters.CrewmemberIds) || !string.IsNullOrWhiteSpace(searchParameters.EmployeeNumber) || (!string.IsNullOrWhiteSpace(searchParameters.DocumentNo) && searchParameters.PersonType == PersonTypes.Crew)) { var crewMemberList = await this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); person.AssignCrewmembers(crewMemberList.Items); person.TotalCrewmembersCount = crewMemberList.TotalResults; } else if ((!string.IsNullOrEmpty(searchParameters.VisitorIds) || searchParameters.Birthdate.HasValue || (!string.IsNullOrWhiteSpace(searchParameters.DocumentNo) && searchParameters.PersonType == PersonTypes.Visitor)) && (!string.IsNullOrEmpty(searchParameters.StartDate) || !string.IsNullOrEmpty(searchParameters.EndDate))) { var visitorList = await this.RetrieveVisitorsAsync(searchParameters, personTypeList); person.AssignVisitors(visitorList.Items); person.TotalVisitorsCount = visitorList.Items.Count; } return person; }
/// <summary> /// Retrieves the person list asynchronous. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <returns> /// Return person list /// </returns> public async Task<ListResult<Person>> RetrieveListAsync(PersonSearchParameter personSearchParameter) { bool isAlertCount = false; if ((string.IsNullOrEmpty(personSearchParameter.IsAlertCount) && string.IsNullOrEmpty(personSearchParameter.IsMessageCount)) || (!string.IsNullOrEmpty(personSearchParameter.IsAlertCount) && Convert.ToBoolean(personSearchParameter.IsAlertCount, CultureInfo.InvariantCulture))) { isAlertCount = true; } var personList = new ListResult<Person>(); var stateroomId = string.Empty; var staterooms = new ListResult<Stateroom>(); if (!string.IsNullOrWhiteSpace(personSearchParameter.Stateroom) && (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) || !personSearchParameter.PersonTypeId.Equals("3"))) { staterooms = await this.shipRepository.GetStateroomListAsync(this.applicationSettings.ShipId, null, personSearchParameter.Stateroom, null, null); stateroomId = PersonMapper.MapStateroomId(personSearchParameter.Stateroom, staterooms).StateroomId; if (string.IsNullOrEmpty(stateroomId)) { return personList; } if (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) || (!string.IsNullOrEmpty(personSearchParameter.PersonTypeId) && string.Equals(personSearchParameter.PersonTypeId, "2"))) { var guests = await this.guestRepository.RetrieveGuests(null, stateroomId, personSearchParameter.VoyageId, null, null, personSearchParameter.Citizenship, null, 1, int.MaxValue); PersonMapper.MapPersonsByGuests(guests, staterooms, personList); var alerts = await this.RetrievePersonAlerts(personSearchParameter, personList.Items.RetrieveIds(p => p.PersonId)); PersonMapper.MapPersonAlerts(alerts, personList); personList.AssignItems(personList.Items.Where(item => isAlertCount ? item.AlertCount > 0 : item.MessageCount > 0).ToList()); personList.TotalResults = personList.Items.Count; personList.GuestTotalResults = personList.TotalResults; } else if (string.Equals(personSearchParameter.PersonTypeId, "1") || (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) && personList.Items.Count == 0)) { var crews = await this.crewClientRepository.RetrieveCrewmembersList(null, null, stateroomId, null, null, 1, int.MaxValue, CrewDepths.Crew); PersonMapper.MapPersonsByCrews(crews, staterooms, personList); var alerts = await this.RetrievePersonAlerts(personSearchParameter, personList.Items.RetrieveIds(p => p.PersonId)); PersonMapper.MapPersonAlerts(alerts, personList); personList.AssignItems(personList.Items.Where(item => isAlertCount ? item.AlertCount > 0 : item.MessageCount > 0).ToList()); personList.TotalResults = personList.Items.Count; personList.CrewTotalResults = personList.TotalResults; } return personList; } List<string> guestIds = new List<string>(), crewIds = new List<string>(), visitorIds = new List<string>(); string personVoyageId = null; if (!string.IsNullOrEmpty(personSearchParameter.PersonTypeId) && personSearchParameter.PersonTypeId.Equals("2") && (!personSearchParameter.IsAll.HasValue || !personSearchParameter.IsAll.Value)) { personVoyageId = personSearchParameter.VoyageId; } if (isAlertCount) { var personAlerts = await this.alertClientRepository.ListPersonAlertsAsync(personSearchParameter.IsAll.GetValueOrDefault(false) ? null : personSearchParameter.PersonTypeId, null, "1", this.applicationSettings.ShipId, personVoyageId, Parts); guestIds = personAlerts.Items.Where(item => item.PersonTypeId == "2").Select(item => item.PersonId).Distinct().ToList(); crewIds = personAlerts.Items.Where(item => item.PersonTypeId == "1").Select(item => item.PersonId).Distinct().ToList(); visitorIds = personAlerts.Items.Where(item => item.PersonTypeId == "3").Select(item => item.PersonId).Distinct().ToList(); } else { var personMessages = await this.alertClientRepository.ListPersonMessagesAsync(personSearchParameter.IsAll.GetValueOrDefault(false) ? null : personSearchParameter.PersonTypeId, null, "1", this.applicationSettings.ShipId, personVoyageId, Parts); guestIds = personMessages.Items.Where(item => item.PersonTypeId == "2").Select(item => item.PersonId).Distinct().ToList(); crewIds = personMessages.Items.Where(item => item.PersonTypeId == "1").Select(item => item.PersonId).Distinct().ToList(); visitorIds = personMessages.Items.Where(item => item.PersonTypeId == "3").Select(item => item.PersonId).Distinct().ToList(); } if (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) || string.Equals(personSearchParameter.PersonTypeId, "2")) { personList = await this.RetrieveGuestsList(personSearchParameter, isAlertCount, guestIds); if (personSearchParameter.IsAll.HasValue && personSearchParameter.IsAll.Value) { var crewResults = await this.RetrieveCrewLists(personSearchParameter, isAlertCount, crewIds); personList.CrewTotalResults = crewResults.Items.Count; if (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) && personList.Items.Count == 0) { personList = crewResults; } var visitorResults = await this.RetrieveVisitorLists(personSearchParameter, visitorIds, isAlertCount); personList.VisitorTotalResults = visitorResults.Items.Count; if (string.IsNullOrEmpty(personSearchParameter.PersonTypeId) && personList.Items.Count == 0) { personList = visitorResults; } } } else if (string.Equals(personSearchParameter.PersonTypeId, "1")) { personList = await this.RetrieveCrewLists(personSearchParameter, isAlertCount, crewIds); if (personSearchParameter.IsAll.HasValue && personSearchParameter.IsAll.Value) { personList.GuestTotalResults = (await this.RetrieveGuestsList(personSearchParameter, isAlertCount, guestIds)).Items.Count; personList.VisitorTotalResults = (await this.RetrieveVisitorLists(personSearchParameter, visitorIds, isAlertCount)).Items.Count; } } else if (string.Equals(personSearchParameter.PersonTypeId, "3")) { personList = await this.RetrieveVisitorLists(personSearchParameter, visitorIds, isAlertCount); if (personSearchParameter.IsAll.HasValue && personSearchParameter.IsAll.Value) { personList.GuestTotalResults = (await this.RetrieveGuestsList(personSearchParameter, isAlertCount, guestIds)).Items.Count; personList.CrewTotalResults = (await this.RetrieveCrewLists(personSearchParameter, isAlertCount, crewIds)).Items.Count; } } return personList; }
/// <summary> /// Searches a person by Guest and Crew. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personTypeList">The person type list.</param> /// <param name="staterooms">The staterooms.</param> /// <returns>Task contains Person Entity.</returns> private async Task<Person> SearchGuestAndCrew(PersonSearchParameter searchParameters, ListResult<PersonTypeEntity> personTypeList, ListResult<DataAccess.Entities.Stateroom> staterooms) { var person = new Person(); if ((searchParameters.PersonType & PersonTypes.All) == PersonTypes.All) { var guestList = this.RetrieveGuests(searchParameters, staterooms, true); var crewMemberList = this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); await Task.WhenAll(crewMemberList, guestList); person.AssignGuests(guestList.Result.Items); person.TotalGuestsCount = guestList.Result.TotalResults; person.AssignCrewmembers(crewMemberList.Result.Items); person.TotalCrewmembersCount = crewMemberList.Result.TotalResults; } else if (searchParameters.PersonType == PersonTypes.Guest) { var guestList = await this.RetrieveGuests(searchParameters, staterooms, true); person.AssignGuests(guestList.Items); person.TotalGuestsCount = guestList.TotalResults; } else if (searchParameters.PersonType == PersonTypes.Crew) { var crewMemberList = await this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); person.AssignCrewmembers(crewMemberList.Items); person.TotalCrewmembersCount = crewMemberList.TotalResults; } return person; }
/// <summary> /// Retrieves the crew lists. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <param name="isAlertCount">if set to <c>true</c> [is alert count].</param> /// <param name="crewIds">The crew ids.</param> /// <returns>The Crew list.</returns> private async Task<ListResult<Person>> RetrieveCrewLists(PersonSearchParameter personSearchParameter, bool isAlertCount, List<string> crewIds) { ListResult<Person> personList = new ListResult<Person>(); if (crewIds.Count == 0 || !string.IsNullOrWhiteSpace(personSearchParameter.Birthdate) || !string.IsNullOrWhiteSpace(personSearchParameter.ReservationNo)) { return personList; } ListResult<Stateroom> staterooms = new ListResult<Stateroom>(); var crews = await this.crewClientRepository.RetrieveCrewmembersList(crewIds.RetrieveIds(id => id), personSearchParameter.LastNameContains, null, personSearchParameter.Citizenship, personSearchParameter.PassportNo, 1, int.MaxValue, CrewDepths.Crew); if (string.IsNullOrWhiteSpace(personSearchParameter.Stateroom)) { var crewStateroomIds = crews.Items.RetrieveIds(a => a.StateroomId); if (!string.IsNullOrWhiteSpace(crewStateroomIds)) { staterooms = await this.RetrieveStaterooms(crewStateroomIds.TrimEnd(','), null); } } PersonMapper.MapPersonsByCrews(crews, staterooms, personList); var alerts = await this.RetrievePersonAlerts(personSearchParameter, personList.Items.RetrieveIds(p => p.PersonId)); PersonMapper.MapPersonAlerts(alerts, personList); personList.AssignItems(personList.Items.Where(item => isAlertCount ? item.AlertCount > 0 : item.MessageCount > 0).ToList()); personList.TotalResults = personList.Items.Count; personList.CrewTotalResults = personList.Items.Count; return personList; }
/// <summary> /// Retrieves the crew members. /// </summary> /// <param name="searchParameter">The search parameter.</param> /// <param name="personTypeList">The person type list.</param> /// <param name="staterooms">The staterooms.</param> /// <returns> /// Return instance of Person entity. /// </returns> private async Task<ListResult<Crewmember>> RetrieveCrewMembers(PersonSearchParameter searchParameter, ListResult<PersonTypeEntity> personTypeList, ListResult<DataAccess.Entities.Stateroom> staterooms) { var crewMemberList = new ListResult<Crewmember>(); if (!string.IsNullOrEmpty(searchParameter.NameContains) || !string.IsNullOrEmpty(searchParameter.LastNameContains) || !string.IsNullOrEmpty(searchParameter.CrewmemberIds) || !string.IsNullOrEmpty(searchParameter.DocumentNo) || !string.IsNullOrEmpty(searchParameter.StateroomIds) || !string.IsNullOrEmpty(searchParameter.EmployeeNumber) || !string.IsNullOrEmpty(searchParameter.AccessCardNumber)) { var crewmembers = await this.personRepository.RetrieveCrew(searchParameter); var crewPersonType = personTypeList.Items.FirstOrDefault(a => a.Name.Equals(PersonTypes.Crew.ToString(), StringComparison.OrdinalIgnoreCase)); if (crewPersonType != null && crewmembers.Items.Count > 0) { var personstatus = await this.RetrievePersonStatus(crewmembers.Items.RetrieveIds(a => a.CrewmemberId), OnboardConstant, crewPersonType.PersonTypeId, searchParameter, null, null); var collection = CrewmemberMapper.MapListAsync(crewmembers, staterooms.Items, null, null); //// Retrieve Safety duties for the crew on the basis of Safety Role Id. crewMemberList.TotalResults = crewmembers.TotalResults; crewMemberList.AssignItems(await MapCrewmemberPersonStatus(collection, personstatus)); } } return crewMemberList; }
/// <summary> /// Retrieves the person alerts. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <param name="personIds">The person ids.</param> /// <returns> /// The alerts. /// </returns> private async Task<ListResult<Entities.AlertType>> RetrievePersonAlerts(PersonSearchParameter personSearchParameter, string personIds) { var isMessage = false; var isAlert = false; if (personSearchParameter.IsMessageCount != null && Convert.ToBoolean(personSearchParameter.IsMessageCount, CultureInfo.CurrentCulture)) { isMessage = true; } if (personSearchParameter.IsAlertCount != null && Convert.ToBoolean(personSearchParameter.IsAlertCount, CultureInfo.CurrentCulture)) { isAlert = true; } var alertSearchParameter = new AlertListRequestSearchParameters { ApplicationId = Convert.ToString(this.applicationSettings.ApplicationId, CultureInfo.CurrentCulture), PersonIds = personIds, IsMessage = isMessage, IsAlert = isAlert, IsExpiredAlert = false }; if (string.IsNullOrWhiteSpace(personSearchParameter.ShipTime)) { var shipTimeTask = await this.shipTimeRepository.GetByIdAsync(this.applicationSettings.ShipId, null); alertSearchParameter.ShipTime = string.IsNullOrWhiteSpace(shipTimeTask) ? DateTime.Now : DateTime.UtcNow.AddMinutes(Convert.ToDouble(shipTimeTask)); } else { alertSearchParameter.ShipTime = DateTime.Parse(personSearchParameter.ShipTime, CultureInfo.InvariantCulture); } var result = new ListResult<Entities.AlertType>(); var alertTemplate = new Entities.AlertTypeCollection(); var alertDetails = await this.RetrieveAlertDetails(alertSearchParameter); foreach (var alert in alertDetails.Items) { if ((alert.ExpiryDate.HasValue && alert.ExpiryDate.Value > alertSearchParameter.ShipTime) || !alert.ExpiryDate.HasValue) { var active = alert.Alerts.Any(personAlert => personAlert.StatusId == "1"); if (active) { alertTemplate.Add(alert); } } } result.AssignItems(alertTemplate); return result; }
/// <summary> /// Searches the person. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="personTypeList">The person type list.</param> /// <param name="staterooms">The staterooms.</param> /// <returns> /// Return person instance. /// </returns> private async Task<Person> SearchPerson(PersonSearchParameter searchParameters, ListResult<PersonTypeEntity> personTypeList, ListResult<DataAccess.Entities.Stateroom> staterooms) { var personType = searchParameters.PersonType.HasValue ? searchParameters.PersonType.Value : PersonTypes.All; var person = new Person(); if ((personType & PersonTypes.All) == PersonTypes.All) { var guestList = this.RetrieveGuests(searchParameters, staterooms, true); var crewMemberList = this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); var visitorList = this.RetrieveVisitorsAsync(searchParameters, personTypeList); await Task.WhenAll(guestList, crewMemberList, visitorList); person.AssignGuests(guestList.Result.Items); person.TotalGuestsCount = guestList.Result.TotalResults; person.AssignCrewmembers(crewMemberList.Result.Items); person.TotalCrewmembersCount = crewMemberList.Result.TotalResults; person.AssignVisitors(visitorList.Result.Items); person.TotalVisitorsCount = visitorList.Result.Items.Count; } else if (personType == PersonTypes.Guest) { var guestList = await this.RetrieveGuests(searchParameters, staterooms, true); person.AssignGuests(guestList.Items); person.TotalGuestsCount = guestList.TotalResults; } else if (personType == PersonTypes.Crew) { var crewMemberList = await this.RetrieveCrewMembers(searchParameters, personTypeList, staterooms); person.AssignCrewmembers(crewMemberList.Items); person.TotalCrewmembersCount = crewMemberList.TotalResults; } else if (personType == PersonTypes.Visitor) { var visitorList = await this.RetrieveVisitorsAsync(searchParameters, personTypeList); person.AssignVisitors(visitorList.Items); person.TotalVisitorsCount = visitorList.Items.Count; } return person; }
/// <summary> /// retrieves person status /// </summary> /// <param name="personIds">The person ids.</param> /// <param name="statusTypeIds">The status type ids.</param> /// <param name="personTypeId">The person type identifier.</param> /// <param name="status">The status.</param> /// <param name="searchParameter">The search parameter.</param> /// <param name="pageNumber">The page number.</param> /// <param name="maxResults">The maximum results.</param> /// <returns> /// Task instance containing List Result of person status. /// </returns> public async Task<ListResult<PersonStatus>> RetrievesPersonStatusListAsync(string personIds, string statusTypeIds, string personTypeId, string status, PersonSearchParameter searchParameter, int? pageNumber, int? maxResults) { var task = await this.personStatusesClient.RetrievePersonStatusListAsync(personIds: personIds, statusTypeIds: statusTypeIds, voyageIds: searchParameter.VoyageIds, personTypeId: personTypeId, status: status, shipIds: searchParameter.ShipId, parts: PersonStatusParts, pageNumber: pageNumber.HasValue ? pageNumber.Value : searchParameter.PageNumber.HasValue ? searchParameter.PageNumber.Value : 1, maxResults: maxResults.HasValue ? maxResults.Value : searchParameter.MaxResults.HasValue ? searchParameter.MaxResults.Value : 0, orderBy: searchParameter.OrderBy); return task != null ? JsonConvert.DeserializeObject<ListResult<PersonStatus>>(task) : default(ListResult<PersonStatus>); }
/// <summary> /// Retrieves the guests. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="staterooms">The staterooms.</param> /// <param name="isReservationInfo">if set to <c>true</c> [is reservation information].</param> /// <returns> /// Task Instance /// </returns> private async Task<ListResult<Guest>> RetrieveGuests(PersonSearchParameter searchParameters, ListResult<DataAccess.Entities.Stateroom> staterooms, bool isReservationInfo) { var guestList = new ListResult<Guest>(); var personSearchParameter = searchParameters; var guests = await this.personRepository.RetrieveGuest(searchParameters); if (guests != null && guests.Items.Count > 0) { guestList.TotalResults = guests.TotalResults; 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.Items.RetrieveIds(a => a.GuestId), PersonStatusConstant, guestPersonType.PersonTypeId, searchParameters, 1, 0) : null; personSearchParameter.GuestIds = guests.Items.RetrieveIds(a => a.GuestId); var guestReservationDetails = isReservationInfo ? await this.guestCruiseDetailManager.RetrieveReservation(personSearchParameter) : new Dictionary<string, DataAccess.Entities.GuestReservationDetail>(); guestList.AssignItems(await this.guestCruiseDetailManager.MapGuestDetails(guests.Items, personStatus, searchParameters.ShipId, guestPersonType != null ? guestPersonType.PersonTypeId : string.Empty, guestReservationDetails, staterooms)); } return guestList; }
/// <summary> /// retrieves person status /// </summary> /// <param name="personIds">personIds attribute</param> /// <param name="statusTypeIds">The status type ids.</param> /// <param name="personTypeId">personTypeId attribute</param> /// <param name="searchParameter">The search parameter.</param> /// <returns> /// list of person status /// </returns> private async Task<ListResult<PersonStatus>> RetrievePersonStatus(string personIds, string statusTypeIds, string personTypeId, PersonSearchParameter searchParameter) { return await this.personRepository.RetrievePersonStatusListAsync(personIds, statusTypeIds, personTypeId, null, searchParameter, 1, 0); }
public async Task RetrieveCrewListAsync() { try { var searchFilter = new PersonSearchParameter { CrewmemberIds = CrewmemberId, NameContains = "abc", PersonType = PersonTypes.Crew, AlertMessageStartDate = DateTime.Now.ToString(), AlertMessageEndDate = DateTime.Now.ToString(), PageNumber = 1, MaxResults = 20 }; CommonDependencies(); this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); this.SetupRetrieveVisitTypeListAsync(); this.SetupShipTime(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.IsTrue(result.Items.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Crewmembers.Count > 0); Assert.AreEqual("212", result.Items.FirstOrDefault().Crewmembers.FirstOrDefault().CrewmemberId); Assert.IsNotNull(result.Items.FirstOrDefault().Crewmembers.FirstOrDefault().PersonalDetail); } finally { this.Dispose(); } }
/// <summary> /// Lists the asynchronous. /// </summary> /// <param name="guestSearchParameters">The guest search parameters.</param> /// <returns> /// Return List Result of person /// </returns> public async Task<ICollection<Guest>> RetrieveTravelWithAsync(GuestSearchParameters guestSearchParameters) { if (guestSearchParameters != null && (!string.IsNullOrWhiteSpace(guestSearchParameters.GuestIds) || !string.IsNullOrWhiteSpace(guestSearchParameters.ReservationNumbers))) { var searchParameters = new PersonSearchParameter { GuestIds = guestSearchParameters.GuestIds, PageNumber = guestSearchParameters.PageNumber, MaxResults = guestSearchParameters.MaxResults }; if (!string.IsNullOrWhiteSpace(guestSearchParameters.ReservationNumbers)) { searchParameters.ReservationIds = await this.GetTravelWithGuest(guestSearchParameters); } return !string.IsNullOrEmpty(searchParameters.ReservationIds) ? await this.MapGuestAlerts(await this.RetrieveGuest(searchParameters), guestSearchParameters) : new Collection<Guest>(); } return new Collection<Guest>(); }
public async Task RetrieveCrewAndVisitorByIdListAsyncTestMethod() { try { var searchFilter = new PersonSearchParameter { VisitorIds = "1", CrewmemberIds = "2", PersonType = PersonTypes.All, AlertMessageStartDate = DateTime.Now.ToString(), AlertMessageEndDate = DateTime.Now.ToString(), ShipId = "5", PageNumber = 1, MaxResults = 5 }; this.SetupData(); this.SetupDataForStatusTypeList(); this.SetupDataForPersonTypeList(); this.SetupRetrievePersonStatusListAsync(); this.SetupVisitorDepartmentListAsync(); this.SetupVisitorVisitPurposeListAsync(); this.SetupRetrieveVisitTypeListAsync(); CommonDependencies(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.IsTrue(result.Items.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Visitors.Count > 0); Assert.IsTrue(result.Items.FirstOrDefault().Crewmembers.Count > 0); Assert.AreEqual("212", result.Items.FirstOrDefault().Crewmembers.FirstOrDefault().CrewmemberId); Assert.AreEqual("22", result.Items.FirstOrDefault().Visitors.FirstOrDefault().VisitorId); } finally { this.Dispose(); } }