/// <summary> /// gets the list of gangway history search parameters /// </summary> /// <param name="searchParameters"> searchParameters identifier</param> /// <returns> returns list of gangway history parameters </returns> public async Task<ListResult<GangwayHistory>> ListAsync(GangwayHistorySearchParameters searchParameters) { var list = new ListResult<GangwayHistory>(); var gangwayHistoryList = await this.personEventClientRepository.RetrieveEventListAsync(new PersonHistorySearchParameters { MachineName = searchParameters.MachineName, EventTypeIds = searchParameters.EventTypeIds, ShipId = searchParameters.ShipId, VoyageIds = searchParameters.VoyageIds, PageNumber = searchParameters.PageNumber, PersonTypeId = searchParameters.PersonTypeId, MaxResults = searchParameters.MaxResults, PersonIds = searchParameters.PersonId }); var personTypeList = await DIContainer.Instance.Resolve<IReferenceDataRepository>().RetrievePersonTypeListAsync(); var guestTypePerson = personTypeList.Items.FirstOrDefault(personType => personType.Name.Equals(GuestType, StringComparison.OrdinalIgnoreCase)); var crewTypePerson = personTypeList.Items.FirstOrDefault(personType => personType.Name.Equals(CrewType, StringComparison.OrdinalIgnoreCase)); var visitorTypePerson = personTypeList.Items.FirstOrDefault(personType => personType.Name.Equals(VisitorType, StringComparison.OrdinalIgnoreCase)); var guestIds = guestTypePerson != null ? gangwayHistoryList.Items.DistinctBy(b => b.PersonId).Where(a => a.PersonTypeId.Equals(guestTypePerson.PersonTypeId)).ToList().RetrieveIds(a => a.PersonId) : null; var crewMemberIds = crewTypePerson != null ? gangwayHistoryList.Items.DistinctBy(b => b.PersonId).Where(a => a.PersonTypeId.Equals(crewTypePerson.PersonTypeId)).ToList().RetrieveIds(a => a.PersonId) : null; var visitorIds = visitorTypePerson != null ? gangwayHistoryList.Items.DistinctBy(b => b.PersonId).Where(a => a.PersonTypeId.Equals(visitorTypePerson.PersonTypeId)).ToList().RetrieveIds(a => a.PersonId) : null; var guests = !string.IsNullOrEmpty(guestIds) ? await this.personRepository.RetrieveGuest(null, guestIds, null, null, null, null, null, null, null, null, null, null, null, null, searchParameters.MaxResults, GuestParts) : null; var crews = !string.IsNullOrEmpty(crewMemberIds) ? GangwayHistoryMapper.MapCrew(await this.personRepository.RetrieveCrew(null, crewMemberIds, null, null, null, null, null, null, null, searchParameters.MaxResults, CrewParts)) : null; var visitors = !string.IsNullOrEmpty(visitorIds) ? await this.personRepository.RetrieveVisitor(null, visitorIds, null, null, null, null, null, null, searchParameters.MaxResults, VisitorParts) : null; foreach (var item in gangwayHistoryList.Items) { MapPersonInformation(personTypeList, guests, crews, visitors, item); list.Items.Add(item); } list.TotalResults = gangwayHistoryList.TotalResults; return list; }
public async Task RetrieveGangwayHistoryListAsync() { var searchFilter = new GangwayHistorySearchParameters { MachineName = string.Empty, PageNumber = 1, MaxResults = 5, EventTypeIds = "1,2,3,4,5,6", OrderBy = "$All", Parts = "$All", ShipId = "5" }; this.SetupData(); var result = await this.manager.ListAsync(searchFilter); Assert.IsNotNull(result); Assert.AreEqual(this.gangwayHistoryList.Items.Count, result.Items.Count); Assert.IsTrue(result.Items.Equals(this.gangwayHistoryList.Items)); Assert.IsNotNull(result.Items.FirstOrDefault(GangwayHistory => this.gangwayHistoryList.Items.Any(item => GangwayHistory.PersonId.Equals(item.PersonId, StringComparison.OrdinalIgnoreCase)))); }
public async Task RetrieveGangwayHistoryTest() { try { var searchFilter = new GangwayHistorySearchParameters { MachineName = "dc", EventTypeIds = "1,2,3,4,5,6", ShipId = "5", OrderBy = "date", Parts = "$All", PageNumber = 2, MaxResults = 2, VoyageIds = "5", PersonTypeId = "1" }; SetupController(this.controller, HttpMethod.Get); this.SetupData(); var response = await this.controller.Get(searchFilter); var result = await response.ExecuteAsync(new CancellationToken(false)); Assert.IsTrue(result.IsSuccessStatusCode == true); Assert.IsTrue(result.StatusCode == HttpStatusCode.OK); ListResultWithMetadata<GangwayHistory> gangwayHistory = null; Assert.IsTrue(result.TryGetContentValue(out gangwayHistory)); } finally { this.Dispose(); } }
/// <summary> /// gets the list of gangway history search parameters /// </summary> /// <param name="searchParameters"> searchParameters identifier</param> /// <returns> returns list of gangway history parameters </returns> public async Task<ListResult<GangwayHistory>> ListAsync(GangwayHistorySearchParameters searchParameters) { return await this.gangwayHistoryRepository.ListAsync(searchParameters); }