public async Task CrewEventListAsyncTestMethod()
        {
            try
            {
                var searchParameters = new PersonEventSearchParameter
                {
                    MaxResults = 5,
                    PageNumber = 1,
                    DateTime = DateTime.Now.ToString(),
                    PersonId = "1",
                    PersonType = "Crew"
                };

                CommonDependencies();
                this.SetupData();
                this.SetupRetrievePersonStatusListAsync();
                this.SetupDataForPersonTypeList();
                await this.manager.PersonEventListAsync(searchParameters);
            }
            finally
            {
                this.Dispose();
            }
        }
Example #2
0
        /// <summary>
        /// Persons the event list asynchronous.
        /// </summary>
        /// <param name="searchParameters">The search parameters.</param>
        /// <returns>
        /// Instance of Event History
        /// </returns>
        public async Task<ListResult<EventHistory>> PersonEventListAsync(PersonEventSearchParameter searchParameters)
        {
            var guestId = string.Empty;
            var crewmemberId = string.Empty;
            var personId = string.Empty;

            var personTypeList = this.referenceDataRepository.RetrievePersonTypeListAsync();
            var staterooms = DIContainer.Instance.Resolve<ShipClientRepository>().RetrieveStateroomListAsync(searchParameters.ShipId);
            await Task.WhenAll(personTypeList, staterooms);

            var personTypeId = personTypeList.Result.Items.FirstOrDefault(a => a.Name.Equals(searchParameters.PersonType));
            searchParameters.PersonTypeId = personTypeId != null ? personTypeId.PersonTypeId : string.Empty;

            if (searchParameters.PersonType.Equals(PersonTypes.Guest.ToString()))
            {
                guestId = searchParameters.PersonId;
            }
            else
            {
                crewmemberId = searchParameters.PersonId;
            }

            var person = await this.RetrievePersonByIdAndDocument(new PersonSearchParameter { GuestIds = guestId, ShipId = searchParameters.ShipId, CrewmemberIds = crewmemberId, }, personTypeList.Result, staterooms.Result);
            if (person.Guests.Count > 0)
            {
                var guest = person.Guests.FirstOrDefault();
                if (guest != null)
                {
                    personId = guest.GuestReservationId;
                }
            }
            else if (person.Crewmembers.Count > 0)
            {
                var crewMember = person.Crewmembers.FirstOrDefault();
                if (crewMember != null)
                {
                    personId = crewMember.EmployeeNo;
                }
            }

            return await this.personRepository.PersonEventListAsync(personId, searchParameters);
        }
        /// <summary>
        /// Persons the event list asynchronous.
        /// </summary>
        /// <param name="personId">The person identifier.</param>
        /// <param name="searchParameters">The search parameters.</param>
        /// <returns>
        /// Instance of Event History
        /// </returns>
        public async Task<ListResult<EventHistory>> PersonEventListAsync(string personId, PersonEventSearchParameter searchParameters)
        {
            var eventHistoryCollection = new ListResult<EventHistory>();
            var eventHistory = new EventHistory();

            ////TODO : Implement Date time value to pass to mas service to retrieve drill events.
            DateTime dateTime;
            try
            {
                DateTime.TryParseExact(searchParameters.DateTime, CustomDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime);
            }
            catch
            {
                dateTime = DateTime.UtcNow;
            }

            //// TODO : Will remove later after 2015-11-23 Release.
            if (dateTime.Equals(DateTime.MinValue))
            {
                dateTime = DateTime.UtcNow;
            }

            var drillEvents = RetrieveDrillEvents(dateTime, personId, searchParameters.PersonType.ToString(CultureInfo.CurrentCulture));
            var gangwayEvents = this.personEventClientRepository.RetrieveEventListAsync(new PersonHistorySearchParameters { ShipId = searchParameters.ShipId, PersonIds = searchParameters.PersonId, PersonTypeId = searchParameters.PersonTypeId, MaxResults = searchParameters.MaxResults, OrderBy = searchParameters.OrderBy, PageNumber = searchParameters.PageNumber, Parts = searchParameters.Parts });

            await Task.WhenAll(drillEvents, gangwayEvents);

            eventHistory.AssignGangwayEvents(PersonEventHistoryMapper.MapListAsync(gangwayEvents.Result.Items));
            eventHistory.AssignDrillEvents(drillEvents.Result);
            eventHistoryCollection.Items.Add(eventHistory);
            eventHistoryCollection.TotalResults = gangwayEvents.Result.TotalResults;
            return eventHistoryCollection;
        }
        public async Task RecentPersonEvents()
        {
            try
            {
                var searchParameter = new PersonEventSearchParameter
                {
                    DateTime = DateTime.Now.ToString(),
                    MaxResults = 5,
                    PageNumber = 1,
                    PersonId = "1",
                    PersonType = "Guest"
                };

                var actionResult = await this.controller.RecentPersonEvents(searchParameter);
                Assert.IsNotNull(actionResult);
            }
            finally
            {
                this.Dispose();
            }
        }
        public async Task PersonEventListAsyncTestMethod()
        {
            try
            {
                DIContainer.Instance.RegisterType<ICountryClient, CountryClient>();
                DIContainer.Instance.RegisterType<IStateClient, StateClient>();
                DIContainer.Instance.RegisterType<IPortClient, PortClient>();
                DIContainer.Instance.RegisterType<IBrandClient, BrandClient>();
                DIContainer.Instance.RegisterType<ILoyaltyLevelTypeClient, LoyaltyLevelTypeClient>();
                DIContainer.Instance.RegisterType<IDocumentTypeClient, DocumentTypeClient>();
                DIContainer.Instance.RegisterType<IPersonTypeClient, PersonTypeClient>();

                DIContainer.Instance.Resolve<IApplicationSetting>().ReferenceDataServiceBaseAddress = "http://Localhost/";
                DIContainer.Instance.Resolve<IApplicationSetting>().MobileAssemblyServiceBaseAddress = "http://Localhost/";
                var searchParameter = new PersonEventSearchParameter
                {
                    MaxResults = 5,
                    PageNumber = 1,
                    DateTime = DateTime.Now.ToString(),
                    PersonId = "1",
                    PersonType = "Guest",
                    ShipId = "5"
                };

                var result = await this.repository.PersonEventListAsync("1", searchParameter);
                Assert.IsNotNull(result);
            }
            finally
            {
                this.Dispose();
            }
        }