private void SetupShipInfoData() { var location = new GangwayLocation { LocationId = "1", LocationTypeId = "123" }; var voyage = new Voyage { DebarkPortId = "2", DestinationId = "1", IsActive = true, EmbarkPortId = "2", Name = "Demo", ShipId = "5", Nights = 2 }; var stateroomCategory = new StateroomCategory { StateroomCategoryId = "1", Category = "123", MediaItemAddress = "http://172.26.248.122/ImagingMediaService/MediaItems/23", StateroomCategoryType = "EDE", StateroomCategoryTypeId = "2" }; var locations = new Collection<GangwayLocation>(); locations.Add(location); var voyages = new Collection<Voyage>(); voyages.Add(voyage); var stateroomCategories = new StateroomCategoryCollection(); stateroomCategories.Add(stateroomCategory); this.shipInfo.AssignGangwayLocations(locations); this.shipInfo.AssignStateroomCategories(stateroomCategories); this.shipInfo.AssignVoyageCollection(voyages); this.shipInfo.ShipId = "5"; }
/// <summary> /// Retrieves the current itinerary. /// </summary> /// <param name="nearestVoyage">The nearest voyage.</param> /// <returns>current itinerary.</returns> private Itinerary RetrieveCurrentItinerary(Voyage nearestVoyage) { Itinerary currentItinerary = null; if (nearestVoyage != null) { nearestVoyage.Itineraries.Iterate(i => i.ItineraryDate = nearestVoyage.EmbarkDate.AddDays(i.Day - 1)); currentItinerary = nearestVoyage.Itineraries.FirstOrDefault(i => i.ItineraryDate.Day == this.workstation.CurrentDateTime.Day); } return currentItinerary; }
/// <summary> /// Function to find out whether itinerary of voyage is changed. /// </summary> /// <param name="nearestVoyage">Active voyage found in service call</param> /// <param name="nearestVoyageOfWorkStation">Active voyage in application</param> /// <returns>True or false</returns> private bool IsItineraryChanged(Voyage nearestVoyage, Voyage nearestVoyageOfWorkStation) { var currentItinerary = this.RetrieveCurrentItinerary(nearestVoyage); var isItineraryCountChanged = nearestVoyageOfWorkStation != null && nearestVoyage != null && nearestVoyageOfWorkStation.Itineraries.Count != nearestVoyage.Itineraries.Count; var isSeaDayChange = currentItinerary != null && (this.workstation.IsSeaDay || currentItinerary.IsSeaDay) ? this.workstation.IsSeaDay != currentItinerary.IsSeaDay : true; var isItineraryDateChanged = currentItinerary != null && currentItinerary.PortId != null && this.workstation.Port.PortId != currentItinerary.PortId && isSeaDayChange; return isItineraryCountChanged || isItineraryDateChanged || IsAnyChangeInItinerary(nearestVoyage, nearestVoyageOfWorkStation); }
/// <summary> /// Function to find out whether there is any change in itinerary. /// </summary> /// <param name="nearestVoyage">Active voyage found in service call</param> /// <param name="nearestVoyageOfWorkStation">Active voyage in application</param> /// <returns>True or false</returns> private static bool IsAnyChangeInItinerary(Voyage nearestVoyage, Voyage nearestVoyageOfWorkStation) { var retrievedActiveVoyageItineraries = nearestVoyage.Itineraries.OrderBy(i => i.Day).ToList(); var applicationActiveVoyageItineraries = nearestVoyageOfWorkStation.Itineraries.OrderBy(i => i.Day).ToList(); var totalItineraryCount = retrievedActiveVoyageItineraries.Count(); for (int i = 0; i < totalItineraryCount; i++) { if (!IsItineraryMatched(retrievedActiveVoyageItineraries[i], applicationActiveVoyageItineraries[i])) { return true; } } return false; }
/// <summary> /// Setups the data. /// </summary> private void SetupData() { Domain.Dependencies.Register(); DataAccess.Dependencies.Register(); this.workstationMock = new Mock<Workstation>(); DIContainer.Instance.RegisterInstance<Workstation>(this.workstationMock.Object); Workstation ws = DIContainer.Instance.Resolve<Workstation>(); ws.Port = new Port { PortId = "1" }; ws.Ship = new Ship { ShipId = "5" }; ws.GangwayLocation = new GangwayLocation { LocationId = "1" }; ws.GangwayServiceBaseAddress = "http://Localhost/"; ws.ConfigurationServiceBaseAddress = "http://Localhost/"; ws.AuthenticationServiceBaseAddress = "http://Localhost/"; ws.AuthorizationServiceBaseAddress = "http://Localhost/"; ws.ConnectionMode = ConnectionMode.Online; var intCollection = new Collection<int>(); intCollection.Add(0); var brand = new Brand { BrandId = "3", Name = "Carnival Breeze", MediaItemAddress = "http://172.26.248.122/ImagingMediaService/MediaItems/23" }; var voyageList = new List<Voyage>(); var voyage = new Voyage { DebarkPortId = "1", EmbarkPortId = "1", DestinationId = "1", MediaItemAddress = "http://172.26.248.122/", VoyageId = "31", Name = "Carnival Voyage", IsActive = true, ShipId = "5", Number = "ccl", DebarkDate = new DateTime(2015, 3, 3), EmbarkDate = new DateTime(2015, 3, 2) }; voyageList.Add(voyage); ws.AssignVoyageList(voyageList); ////this.repository = new Mock<IRepository>(); ////this.embarkationStatisticsRepositoryMock = new Mock<EmbarkationStatisticsRepository>(); this.personServiceRepositoryMock = new Mock<PersonServiceRepository>(); this.referenceDataRepositoryMock = new Mock<ReferenceDataRepository>(); ////this.photoCaptureRepositoryMock = new Mock<PhotoCaptureRepository>(); ////this.shipTimeRepositoryMock = new Mock<ShipTimeRepository>(); ////this.referenceDataRepositoryMock = new Mock<ReferenceDataRepository>(); ////this.gangwayEventRepositoryMock = new Mock<GangwayEventRepository>(); ////this.guestClient = new Mock<IGuestClient>(); ////this.personClient = new Mock<IPersonsClient>(); ////DIContainer.Instance.RegisterInstance<IGuestClient>(this.guestClient.Object); ////DIContainer.Instance.RegisterInstance<IPersonsClient>(this.personClient.Object); ////DIContainer.Instance.RegisterInstance<IRepository>(this.repository.Object); DIContainer.Instance.RegisterInstance<ReferenceDataRepository>(this.referenceDataRepositoryMock.Object); ////DIContainer.Instance.RegisterInstance<EmbarkationStatisticsRepository>(this.embarkationStatisticsRepositoryMock.Object); ////DIContainer.Instance.RegisterInstance<GangwayEventRepository>(this.gangwayEventRepositoryMock.Object); ////DIContainer.Instance.RegisterInstance<PhotoCaptureRepository>(this.photoCaptureRepositoryMock.Object); DIContainer.Instance.RegisterInstance<PersonServiceRepository>(this.personServiceRepositoryMock.Object); ////DIContainer.Instance.RegisterInstance<ShipTimeRepository>(this.shipTimeRepositoryMock.Object); var cruiseDetails = new GuestCruiseDetail { BeaconId = string.Empty, BerthNumber = string.Empty, IdentificationId = string.Empty, LoyaltyLevelTypeId = string.Empty, ReservationId = string.Empty, Stateroom = "0000" }; var personDetail = new PersonalDetail { CitizenshipCountryId = string.Empty, FirstName = string.Empty, LastName = string.Empty, MiddleName = string.Empty, Title = string.Empty, PreferredName = string.Empty, MaritalStatus = string.Empty, Nickname = string.Empty, Occupation = string.Empty, DocumentNumber = string.Empty, Suffix = string.Empty, DocumentTypeId = "1" }; this.person = new Person { TotalResults = 1 }; CrewmemberCollection crewMembers = new CrewmemberCollection(); crewMembers.Add(new Crewmember { CrewmemberId = string.Empty, CrewmemberTypeId = "1", SecurityPhotoAddress = string.Empty, ChargeId = string.Empty, EmployeeNo = string.Empty, LastEvent = string.Empty, PersonalDetail = personDetail }); person.AssignCrewmembers(crewMembers); GuestCollection guests = new GuestCollection(); var checkInDetail = new CheckInDetail { ApplicationId = string.Empty, LocationId = "1", LocationTypeId = "1", MachineName = "Machine", Station = "station", UserId = "user" }; var cruiseDetail = new GuestCruiseDetail { BeaconId = string.Empty, CheckInDetail = checkInDetail, LoyaltyLevelTypeId = "1", ReservationId = "1", Stateroom = "00000", ReservationStatusId = "0000089", StateroomCategoryTypeId = "aaasad" }; guests.Add(new Guest { GuestId = "0001", PersonalDetail = personDetail, Age = 0, CruiseDetail = cruiseDetail, SecurityPhotoAddress = string.Empty, }); VisitorCollection visitors = new VisitorCollection(); visitors.Add(new Visitor { VisitorId = "0003", PersonalDetail = personDetail, SecurityPhotoAddress = string.Empty, }); this.person.AssignGuests(guests); this.person.AssignVisitors(visitors); this.personTypes = new List<PersonType>(); personTypes.Add(PersonType.Guest); this.personServiceRepositoryMock.Setup(data => data.RetrievePersonsBySearchText(It.IsNotNull<string>(), It.IsAny<string>(), It.IsAny<IList<PersonType>>(), It.IsAny<SearchType>(), It.IsAny<string>(), It.IsAny<string>(), 0, 0, It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(this.person)); var documentTypes = new DocumentTypeCollection(); documentTypes.Add(new DocumentType { CountryId = "232", Code = "USA", DocumentTypeId = "1", Name = "Passport" }); var referencedata = new ReferenceData(); referencedata.AssignDocumentTypes(documentTypes); this.referenceDataRepositoryMock.Setup(data => data.RetrieveReferenceDataAsync()).Returns(Task.FromResult(referencedata)); ////this.personClient.Setup(data => data.RetrievePersonsAsync("5", "ab", null, null, "0001", null, null, "Guest", null, null, null, null, null, 0, 0)).Returns(RetrieveData()); }
/// <summary> /// Maps the voyages. /// </summary> /// <param name="dataReader">The data reader.</param> /// <returns>The Collection of voyages</returns> private static async Task<ICollection<Voyage>> MapVoyages(SqlDataReader dataReader) { var voyages = new Collection<Voyage>(); IDictionary<string, ICollection<Itinerary>> itineraries = new Dictionary<string, ICollection<Itinerary>>(); if (dataReader != null) { while (await dataReader.ReadAsync()) { var voyage = new Voyage { VoyageId = dataReader.Int32Field(VoyageId).ToString(), ShipId = dataReader.ByteField(ShipId).ToString(), Number = dataReader.StringField(Number), Name = dataReader.StringField(Name), EmbarkDate = dataReader.DateTimeField(EmbarkDate), DebarkDate = dataReader.DateTimeField(DebarkDate), EmbarkPortId = dataReader.Int32Field(EmbarkPortId).ToString(), DebarkPortId = dataReader.Int32Field(DebarkPortId).ToString(), Nights = dataReader.ByteField(Nights), DestinationId = dataReader.StringField(DestinationName), IsActive = dataReader.BooleanField(IsActive), MediaItemAddress = dataReader.StringField(MediaItemAddress) }; byte[] bytes = await voyage.MediaItemAddress.ImageAddressToByteArray(); voyage.ItineraryGraphImage = bytes.ToBitmapSource(); voyages.Add(voyage); } } return voyages; }