예제 #1
0
        /// <summary>
        /// Filter the object DRM adn Episode count criteria
        /// </summary>
        /// <param name="JsonObject">Object</param>
        /// <returns>Object filtered</returns>
        public static FilteredPayLoad FilterFullPayLoad(FullPayLoad JsonObject)
        {
            try
            {
                if (JsonObject == null)
                {
                    throw new NullReferenceException("Please inform a Full Pay Load object");
                }

                if (JsonObject.PayLoad == null)
                {
                    throw new NullReferenceException("Please inform a Full Pay Load object");
                }

                IEnumerable <PayLoad> filteredResult = JsonObject.PayLoad.Where(p => p.Drm && p.EpisodeCount > 0 && p.Image != null);
                List <ShortPayLoad>   formatedResult = filteredResult.Select(p => new ShortPayLoad()
                {
                    Image = p.Image.ShowImage, Slug = p.Slug, Title = p.Title
                }).ToList();

                FilteredPayLoad result = new FilteredPayLoad()
                {
                    Response = formatedResult
                };
                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
 /// <summary>
 /// Comparing the source and the result
 /// </summary>
 /// <param name="filtered">filtered list</param>
 /// <param name="full">full list</param>
 public void Compare(FilteredPayLoad filtered, FullPayLoad full)
 {
     foreach (var response in filtered.Response.Take(5000))
     {
         full.PayLoad.Any(p => p.Image != null && p.Image.ShowImage == response.Image).Should().BeTrue();
         full.PayLoad.Any(p => p.Slug == response.Slug).Should().BeTrue();
         full.PayLoad.Any(p => p.Title == response.Title).Should().BeTrue();
     }
 }