public PerformanceDetailsDataModelBase GetInformationAboutPerformance(string Accountid, string languageCode, int perforamanceId) { var performance = GetPerformance(InitializeClient(), perforamanceId).Result; var media = GetMainImage(InitializeClient(), performance.Featured_media).Result; var galleryImage = performance.AcfInfo.AboutGroup.Gallery == null ? null : (from image in GalleryInfo.Gallery select image.Sizes.Large).ToList(); string description = Regex.Replace(performance.Content.Rendered, @"(</p>)", "\n"); description = Regex.Replace(description, @"(<.*?>)", string.Empty); description = WebUtility.HtmlDecode(description); description = description.Trim(); string title = WebUtility.HtmlDecode(performance.Title.Rendered); var performanceDetailsDataModelWp = new PerformanceDetailsDataModelWp { Title = title, Description = description, MainImage = media.Media_details.Sizes.Full.Source_url, GalleryImage = galleryImage, MinimumAge = performance.AcfInfo.AboutGroup.Age, Duration = performance.AcfInfo.AboutGroup.Duration, }; if (performance.AcfInfo.AboutGroup.Price.Contains('-')) { string[] Prices = (performance.AcfInfo.AboutGroup.Price).Split('-'); performanceDetailsDataModelWp.MinPrice = Convert.ToInt32(Prices[0]); performanceDetailsDataModelWp.MaxPrice = Convert.ToInt32(Prices[1]); } else { performanceDetailsDataModelWp.MinPrice = Convert.ToInt32(performance.AcfInfo.AboutGroup.Price); performanceDetailsDataModelWp.MaxPrice = Convert.ToInt32(performance.AcfInfo.AboutGroup.Price); } return(performanceDetailsDataModelWp); }
public void SetUp() { var creativeTeam = new List <TeamMember> { new TeamMember { FirstName = "Vasyl", LastName = "Diakiv", Role = "Producer", RoleKey = "PRODUCER" }, new TeamMember { FirstName = "Vlad", LastName = "Mamai", Role = "Painter", RoleKey = "PAINTER" }, new TeamMember { FirstName = "Oleh", LastName = "Sihunov", Role = "Composer", RoleKey = "COMPOSER" } }; var tags = new List <string> { "art", "comics" }; var performanceDetails = new PerformanceDetailsDataModelWp() { MainImage = "jpg", GalleryImage = new List <string>() { "jpg", "jpg" }, Duration = 50, MaxPrice = 80, MinPrice = 35, MinimumAge = 12, Description = "за однойменним твором Б. Стельмаха\n\nПроп", Title = "Тарас" }; var isChecked = false; performance = new PerformanceDetailsWpDTO() { Title = performanceDetails.Title, Duration = performanceDetails.Duration, MinimumAge = performanceDetails.MinimumAge, MinPrice = performanceDetails.MinPrice, MaxPrice = performanceDetails.MaxPrice, Description = performanceDetails.Description, MainImage = performanceDetails.MainImage, GalleryImage = performanceDetails.GalleryImage, HashTag = from tg in tags select tg, TeamMember = from tm in creativeTeam select new TeamMemberDTO() { FirstName = tm.FirstName, LastName = tm.LastName, Role = tm.Role, RoleKey = tm.RoleKey, }, }; unitOfWorkMock = new Mock <ITheaterScheduleUnitOfWork>(); performanceDetailsRepositoryMock = new Mock <IPerformanceDetailsRepository>(); tagRepositoryMock = new Mock <ITagRepository>(); creativeTeamRepositoryMock = new Mock <ICreativeTeamRepository>(); isCheckedPerformanceRepositoryMock = new Mock <IIsCheckedPerformanceRepository>(); object response = performance; memoryMock = new Mock <IMemoryCache>(); memoryMock .Setup(x => x.TryGetValue(It.IsAny <object>(), out response)) .Returns(true); creativeTeamRepositoryMock.Setup(x => x.GetCreativeTeam( It.IsAny <string>(), It.IsAny <int>())) .Returns(creativeTeam); isCheckedPerformanceRepositoryMock.Setup(x => x.IsChecked( It.IsAny <string>(), It.IsAny <int>())) .Returns(true); tagRepositoryMock.Setup(x => x.GetTagsByPerformanceId( It.IsAny <int>())) .Returns(Task.FromResult(tags as IEnumerable <string>)); performanceDetailsRepositoryMock.Setup(x => x.GetInformationAboutPerformance( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())) .Returns(performanceDetails); performanceDetailsService = new PerformanceDetailsServiceWp( unitOfWorkMock.Object, performanceDetailsRepositoryMock.Object, tagRepositoryMock.Object, creativeTeamRepositoryMock.Object, isCheckedPerformanceRepositoryMock.Object, memoryMock.Object); }