public async Task RetrieveGuestsTest() { try { this.SetupGetRequests(); PersonStatusHistorySearchParameters objParam = new PersonStatusHistorySearchParameters(); objParam.MaxResults = 50; objParam.PageNumber = 1; this.guestManager.Setup(mokeItem => mokeItem.GuestInfoListByStatusAsync(It.IsNotNull<PersonStatusHistorySearchParameters>())).Returns(Task.FromResult(new ListResult<PersonStatusHistory>())); var response = await this.guestController.RetrieveGuestInfoByStatus(objParam); var result = await response.ExecuteAsync(new CancellationToken(false)); Assert.IsTrue(result.IsSuccessStatusCode); Assert.AreEqual(HttpStatusCode.OK, result.StatusCode); } finally { this.Dispose(); } }
public async Task RetrieveCrewsTest() { try { this.SetupGetRequests(); PersonStatusHistorySearchParameters objParam = new PersonStatusHistorySearchParameters(); objParam.MaxResults = 50; objParam.PageNumber = 1; var personStatusHistoryList = new ListResult<PersonStatusHistory>(); personStatusHistoryList.Items.Add(new PersonStatusHistory { FirstName = "Test" }); this.crewManager.Setup(mokeItem => mokeItem.CrewInfoListByStatusAsync(It.IsNotNull<PersonStatusHistorySearchParameters>())).Returns(Task.FromResult(personStatusHistoryList)); var response = await this.crewController.RetrieveCrewInfoByStatus(objParam); var result = await response.ExecuteAsync(new CancellationToken(false)); ListResult<PersonStatusHistory> crewMembers = null; Assert.IsTrue(result.IsSuccessStatusCode); Assert.IsTrue(result.TryGetContentValue(out crewMembers)); Assert.AreEqual(personStatusHistoryList.Items, crewMembers.Items); } finally { this.Dispose(); } }
/// <summary> /// Assigns the person status list. /// </summary> /// <param name="searchFilters">The search filters.</param> public void AssignPersonStatusList(PersonStatusHistorySearchParameters searchFilters) { this.personStatusHistorySearchParameters = searchFilters; }
/// <summary> /// Gets the dashboard statistics detail asynchronous. /// </summary> /// <param name="searchParameter">The search parameter.</param> /// <returns>Task Instance containing string value.</returns> public async Task<ListResult<DashboardStatistics>> GetDashboardStatisticsDetailAsync(PersonStatusHistorySearchParameters searchParameter) { var task = await this.personStatusesClient.GetDashboardStatisticsDetailAsync(searchParameter.ShipId, searchParameter.VoyageIds, searchParameter.PersonTypeId, searchParameter.StatsDate, searchParameter.SummaryKeyType.ToString(), searchParameter.PageNumber, searchParameter.MaxResults); return task != null ? JsonConvert.DeserializeObject<ListResult<DashboardStatistics>>(task) : default(ListResult<DashboardStatistics>); }
/// <summary> /// Gets the person status history asynchronous. /// </summary> /// <param name="searchFilter">The search filter.</param> /// <returns> /// the persons status /// </returns> public async Task<ListResult<PersonStatusHistory>> GetPersonStatusHistoryAsync(PersonStatusHistorySearchParameters searchFilter) { return await this.personRepository.GetPersonStatusHistoryAsync(searchFilter); }
public async Task ListVisitorExpectedTodayTestAsync() { try { var searchParameters = new PersonStatusHistorySearchParameters { MaxResults = 10, PageNumber = 1, OrderBy = string.Empty, Parts = string.Empty, PersonTypeId = "3", ShipId = "1", SummaryKeyType = StatisticsType.ExpectedToday, VoyageIds = "1" }; CommonDependencies(); var result = await this.manager.ListAsync(searchParameters); } finally { this.Dispose(); } }
public async Task CrewListAsyncTestMethod() { try { var searchParameters = new PersonStatusHistorySearchParameters { MaxResults = 10, PageNumber = 1, OrderBy = string.Empty, Parts = string.Empty, PersonTypeId = "1", ShipId = "1", SummaryKeyType = StatisticsType.Onboard, VoyageIds = "1" }; CommonDependencies(); this.SetupDashboardStatistics(); var result = await this.manager.ListAsync(searchParameters); Assert.IsNotNull(result); } finally { this.Dispose(); } }
/// <summary> /// Gets the person status history asynchronous. /// </summary> /// <param name="searchFilter">The search filter.</param> /// <returns>the person status history</returns> public async Task<ListResult<PersonStatusHistory>> GetPersonStatusHistoryAsync(PersonStatusHistorySearchParameters searchFilter) { string dataResource = searchFilter.PersonTypeId == "2" ? PersonStatusHistoryGuestDataResource : PersonStatusHistoryCrewDataResource; if (!searchFilter.PageNumber.HasValue) { searchFilter.PageNumber = DefaultPageNumber; } if (!(searchFilter.MaxResult > 0)) { searchFilter.MaxResult = int.MaxValue; } var uri = string.Format(GetPersonStatusHistoryRelativeAddress, BaseAddress, dataResource, searchFilter.ShipId, searchFilter.VoyageIds, searchFilter.StatsDate, searchFilter.StatusType, searchFilter.PersonTypeId, searchFilter.MaxResult, searchFilter.PageNumber); var personStatus = await this.httpClientHelper.Retrieve(uri, new CancellationToken(false)); var personStatusData = !string.IsNullOrEmpty(personStatus) ? JsonConvert.DeserializeObject<ListResult<PersonStatusHistory>>(personStatus) : default(ListResult<PersonStatusHistory>); return personStatusData; }
/// <summary> /// Gets the dashboard statistics detail asynchronous. /// </summary> /// <param name="searchParameter">The search parameter.</param> /// <returns> /// Task contains person ids in return /// </returns> public async Task<ListResult<DashboardStatistics>> GetDashboardStatisticsDetailAsync(PersonStatusHistorySearchParameters searchParameter) { return await this.personStatusClientRepository.GetDashboardStatisticsDetailAsync(searchParameter); }
/// <summary> /// Guests the information list by status asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns>Crew list</returns> public async Task<ListResult<PersonStatusHistory>> CrewInfoListByStatusAsync(PersonStatusHistorySearchParameters searchParameters) { var list = new ListResult<PersonStatusHistory>(); var crews = default(ListResult<Crewmember>); string shipTime = string.Empty; var staterooms = this.shipRepository.GetStateroomListAsync(searchParameters.ShipId, null, null, null, null); var personTypeList = this.referenceDataRepository.RetrievePersonTypeListAsync(); await Task.WhenAll(staterooms, personTypeList); if (string.IsNullOrEmpty(searchParameters.StatsDate)) { var shipTimeTask = await this.shipTimeRepository.GetByIdAsync(searchParameters.ShipId, null); shipTime = string.IsNullOrWhiteSpace(shipTimeTask) ? string.Empty : DateTime.UtcNow.AddMinutes(Convert.ToDouble(shipTimeTask)).ToShortDateString(); } else { shipTime = Convert.ToDateTime(searchParameters.StatsDate).ToShortDateString(); } var personIdList = await this.personStatusRepository.GetDashboardStatisticsDetailAsync(searchParameters.ShipId, searchParameters.VoyageIds, searchParameters.PersonTypeId, shipTime, searchParameters.StatusType, searchParameters.PageNumber, searchParameters.MaxResults); if (personIdList != null && personIdList.Items.Count > 0) { var crewMemberIds = personIdList.Items.RetrieveIds(a => a.PersonId); crews = !string.IsNullOrEmpty(crewMemberIds) ? MapCrew(await this.crewRepository.RetrieveCrewmembers(crewMemberIds, null, null, null, null, null, null, null, null, null, searchParameters.MaxResults, CrewParts)) : null; foreach (var item in personIdList.Items) { list.Items.Add(MapPersonInformation(personTypeList.Result, crews, staterooms.Result, item)); } list.TotalResults = personIdList.TotalResults; } return list; }
/// <summary> /// Guests the information list by status asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns>Guest list</returns> public async Task<ListResult<PersonStatusHistory>> GuestInfoListByStatusAsync(PersonStatusHistorySearchParameters searchParameters) { var list = new ListResult<PersonStatusHistory>(); string shipTime = string.Empty; var guests = default(ListResult<Guest>); var staterooms = this.shipRepository.GetStateroomListAsync(searchParameters.ShipId, null, null, null, null); var personTypeList = this.referenceDataRepository.RetrievePersonTypeListAsync(); await Task.WhenAll(staterooms, personTypeList); if (string.IsNullOrEmpty(searchParameters.StatsDate)) { var shipTimeTask = await this.shipTimeRepository.GetByIdAsync(searchParameters.ShipId, null); shipTime = string.IsNullOrWhiteSpace(shipTimeTask) ? string.Empty : DateTime.UtcNow.AddMinutes(Convert.ToDouble(shipTimeTask)).ToShortDateString(); } else { shipTime = Convert.ToDateTime(searchParameters.StatsDate).ToShortDateString(); } if (searchParameters.StatusType.Equals(LeavingTodayConstant, StringComparison.OrdinalIgnoreCase)) { ////Guest client call } else { var personIdList = await this.personStatusRepository.GetDashboardStatisticsDetailAsync(searchParameters.ShipId, searchParameters.VoyageIds, searchParameters.PersonTypeId, shipTime, searchParameters.StatusType, searchParameters.PageNumber, searchParameters.MaxResults); if (personIdList != null && personIdList.Items.Count > 0) { var guestIds = personIdList.Items.RetrieveIds(a => a.PersonId); guests = !string.IsNullOrEmpty(guestIds) ? await this.guestRepository.RetrieveGuestReservations(null, null, null, null, null, null, null, guestIds, null, null, null, null, null, null, searchParameters.MaxResults, GuestParts) : null; foreach (var item in personIdList.Items) { list.Items.Add(MapPersonInformation(personTypeList.Result, guests, staterooms.Result, item)); } list.TotalResults = personIdList.TotalResults; } } return list; }
public async Task RetrievePersonInfoByStatusTest() { try { var searchParameters = new PersonStatusHistorySearchParameters { MaxResults = 10, PageNumber = 1, OrderBy = string.Empty, Parts = string.Empty, PersonTypeId = "1", ShipId = "1", SummaryKeyType = StatisticsType.Onboard, VoyageIds = "1" }; var response = await this.controller.RetrievePersonInfoByStatus(searchParameters); var result = await response.ExecuteAsync(new CancellationToken(false)); Assert.IsTrue(result.IsSuccessStatusCode); Assert.IsTrue(result.StatusCode == HttpStatusCode.OK); } finally { this.Dispose(); } }
/// <summary> /// Guests the information list by status asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns>guest list</returns> public async Task<ListResult<PersonStatusHistory>> GuestInfoListByStatusAsync(PersonStatusHistorySearchParameters searchParameters) { return await this.guestData.GuestInfoListByStatusAsync(searchParameters); }
/// <summary> /// Lists the asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns> /// Person Status History. /// </returns> public async Task<ListResult<PersonStatusHistory>> ListAsync(PersonStatusHistorySearchParameters searchParameters) { var list = new ListResult<PersonStatusHistory>(); var guests = default(ListResult<Guest>); var crews = default(ListResult<Crewmember>); var visitors = default(ListResult<Visitor>); var staterooms = DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(searchParameters.ShipId); var personTypeList = DIContainer.Instance.Resolve<IReferenceDataRepository>().RetrievePersonTypeListAsync(); await Task.WhenAll(staterooms, personTypeList); var guestTypePerson = personTypeList.Result.Items.FirstOrDefault(personType => personType.Name.Equals(GuestType, StringComparison.OrdinalIgnoreCase)); var crewTypePerson = personTypeList.Result.Items.FirstOrDefault(personType => personType.Name.Equals(CrewType, StringComparison.OrdinalIgnoreCase)); var visitorTypePerson = personTypeList.Result.Items.FirstOrDefault(personType => personType.Name.Equals(VisitorType, StringComparison.OrdinalIgnoreCase)); if (!string.IsNullOrEmpty(searchParameters.PersonTypeId)) { if (searchParameters.SummaryKeyType == StatisticsType.LeavingToday && searchParameters.PersonTypeId == guestTypePerson.PersonTypeId) { ////Guest } else if (searchParameters.SummaryKeyType == StatisticsType.ExpectedToday && searchParameters.PersonTypeId == visitorTypePerson.PersonTypeId) { visitors = await RetrieveExpectedTodayVisitors(searchParameters, list, visitorTypePerson); } else { var dashboardStatistics = await this.embarkationStatisticsRepository.GetDashboardStatisticsDetailAsync(new PersonStatusHistorySearchParameters { ShipId = searchParameters.ShipId, VoyageIds = searchParameters.VoyageIds, PersonTypeId = searchParameters.PersonTypeId, StatsDate = searchParameters.StatsDate, SummaryKeyType = searchParameters.SummaryKeyType, PageNumber = searchParameters.PageNumber, MaxResults = searchParameters.MaxResults }); if (dashboardStatistics != null && dashboardStatistics.Items.Count > 0) { var personIds = dashboardStatistics.Items.RetrieveIds(a => a.PersonId); if (!string.IsNullOrEmpty(guestTypePerson.PersonTypeId) && searchParameters.PersonTypeId.Equals(guestTypePerson.PersonTypeId)) { guests = await DIContainer.Instance.Resolve<IPersonRepository>().RetrieveGuest(new PersonSearchParameter { GuestIds = personIds, MaxResults = searchParameters.MaxResults, Parts = GuestParts }); } else if (!string.IsNullOrEmpty(crewTypePerson.PersonTypeId) && searchParameters.PersonTypeId.Equals(crewTypePerson.PersonTypeId)) { crews = EmbarkationStatisticsMapper.MapCrew(await DIContainer.Instance.Resolve<IPersonRepository>().RetrieveCrew(new PersonSearchParameter { CrewmemberIds = personIds, MaxResults = searchParameters.MaxResults, Parts = CrewParts })); } else if (!string.IsNullOrEmpty(visitorTypePerson.PersonTypeId) && searchParameters.PersonTypeId.Equals(visitorTypePerson.PersonTypeId)) { visitors = await DIContainer.Instance.Resolve<IPersonRepository>().RetrieveVisitor(new PersonSearchParameter { VisitorIds = personIds, MaxResults = searchParameters.MaxResults, Parts = VisitorParts }); } foreach (var item in dashboardStatistics.Items) { list.Items.Add(EmbarkationStatisticsMapper.MapPersonInformation(personTypeList.Result, guests, crews, visitors, staterooms.Result, item)); } list.TotalResults = dashboardStatistics.TotalResults; } } } return list; }
/// <summary> /// Retrieves the expected today visitors. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <param name="list">The list.</param> /// <param name="personTypeEntity">The person type entity.</param> /// <returns> /// Return visitor list /// </returns> private static async Task<ListResult<Visitor>> RetrieveExpectedTodayVisitors(PersonStatusHistorySearchParameters searchParameters, ListResult<PersonStatusHistory> list, PersonTypeEntity personTypeEntity) { var visitors = await DIContainer.Instance.Resolve<IPersonRepository>().RetrieveVisitor(new PersonSearchParameter { StartDate = searchParameters.StatsDate, MaxResults = searchParameters.MaxResults, Parts = VisitorParts }); if (visitors != null && visitors.Items.Count > 0) { foreach (var visitor in visitors.Items) { list.Items.Add(EmbarkationStatisticsMapper.MapVisitorInformation(visitor, personTypeEntity)); } } list.TotalResults = list.Items.Count; return visitors; }
/// <summary> /// Guests the information list by status asynchronous. /// </summary> /// <param name="searchParameters">The search parameters.</param> /// <returns>guest list</returns> public async Task<ListResult<PersonStatusHistory>> CrewInfoListByStatusAsync(PersonStatusHistorySearchParameters searchParameters) { return await this.crewData.CrewInfoListByStatusAsync(searchParameters); }