/// <summary> /// Maps the asynchronous. /// </summary> /// <param name="stateroomCategory">The stateroom category.</param> /// <param name="entityStateroomCategoryType">Type of the stateroom category.</param> /// <returns> /// stateroom category /// </returns> private static StateroomCategory MapAsync(Entities.StateroomCategory stateroomCategory, Entities.StateroomCategoryType entityStateroomCategoryType) { var stateroomCategoryData = new StateroomCategory(); if (stateroomCategory != null) { stateroomCategoryData.StateroomCategoryType = stateroomCategory.StateroomCategoryType; stateroomCategoryData.StateroomCategoryTypeId = stateroomCategory.StateroomCategoryTypeId; stateroomCategoryData.Category = stateroomCategory.Category; stateroomCategoryData.StateroomCategoryId = stateroomCategory.StateroomCategoryId; if (entityStateroomCategoryType != null && !string.IsNullOrEmpty(ApplicationSetting.MediaTypeId)) { var stateroomCategoryType = entityStateroomCategoryType.MediaItems != null ? entityStateroomCategoryType.MediaItems.FirstOrDefault(a => a.MediaTypeId.Equals(ApplicationSetting.MediaTypeId, StringComparison.OrdinalIgnoreCase)) : null; if (stateroomCategoryType != null) { stateroomCategoryData.MediaItemAddress = stateroomCategoryType.MediaItemAddress; } } } return stateroomCategoryData; }
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> /// set up the ship info data /// </summary> private void SetShipInfoData() { this.gangwayLocation = new GangwayLocation { LocationId = "2365", LocationTypeId = "1", Name = "DK3 Mid Port" }; this.gangwayLocations = new Collection<GangwayLocation>(); this.gangwayLocations.Add(this.gangwayLocation); this.referenceDataRepository.Setup(data => data.RetrieveGangwayLocationListAsync("5")).Returns(Task.FromResult(this.gangwayLocations)); this.stateroomCategory = new StateroomCategory { StateroomCategoryType = "Inside Staterooms", StateroomCategoryTypeId = "1" }; var stateroomCategories = new ListResult<StateroomCategory>(); stateroomCategories.Items.Add(this.stateroomCategory); this.referenceDataRepository.Setup(data => data.RetrieveGangwayLocationListAsync("5")).Returns(Task.FromResult(this.gangwayLocations)); this.referenceDataRepository.Setup(data => data.RetrieveStateroomCategoryListAsync("5")).Returns(Task.FromResult(stateroomCategories)); }
/// <summary> /// Maps the stateroom categories. /// </summary> /// <param name="dataReader">The data reader.</param> /// <returns>The collection of stateroom category</returns> private static async Task<StateroomCategoryCollection> MapStateroomCategories(SqlDataReader dataReader) { var stateroomCategories = new StateroomCategoryCollection(); if (dataReader != null) { while (await dataReader.ReadAsync()) { var stateroomCategory = new StateroomCategory { StateroomCategoryTypeId = dataReader.Int16Field(StateroomCategoryTypeId).ToString(), StateroomCategoryType = dataReader.StringField(StateroomCategoryType), MediaItemAddress = dataReader.StringField(MediaItemAddress), Category = dataReader.StringField(Category) }; byte[] bytes = await stateroomCategory.MediaItemAddress.ImageAddressToByteArray(); stateroomCategory.StateroomIcon = bytes.ToBitmapSource(); stateroomCategories.Add(stateroomCategory); } } return stateroomCategories; }