예제 #1
0
        public Product BuildProduct(IgdbGame game)
        {
            Product product = new Product
            {
                Name             = game.Name,
                Summary          = game.Summary,
                TotalRating      = (int)game.Rating,
                FirstReleaseDate = UnixTimestampToDateTime(game.First_release_date),
                IgdbId           = game.Id
            };

            if (game.Cover != null && game.Cover.Url != null)
            {
                product.CoverUrl = ReplaceScreenSize("screenshot_big", game.Cover.Url);
            }

            if (game.Screenshots != null)
            {
                product.Screenshots = new List <Screenshot>();
                foreach (IgdbScreenshot screenshot in game.Screenshots)
                {
                    if (screenshot.Url != null)
                    {
                        Screenshot screen = new Screenshot
                        {
                            ScreenshotUrl = ReplaceScreenSize("screenshot_huge", screenshot.Url)
                        };
                        product.Screenshots.Add(screen);
                    }
                }
            }

            return(product);
        }
예제 #2
0
 public ReviewViewModel(IgdbGame model)
 {
     CriticsRating      = string.Format("{0:0.00}", model.AggregatedRating);
     CriticsRatingCount = model.AggregatedRatingCount;
     GameModes          = model.GameModes?.Select(x => x.Name).ToList() ?? new List <string>();
     Genres             = model.Genres?.Select(x => x.Name).ToList() ?? new List <string>();
     UserRating         = string.Format("{0:0.00}", model.Rating);
     UserRatingCount    = model.RatingCount;
     TotalRating        = string.Format("{0:0.00}", model.TotalRating);
     TotalRatingCount   = model.TotalRatingCount;
     ReleaseDates       = model.ReleaseDates?.Select(x => new ReleaseDate {
         Date = x.Date, Platform = x.Platform?.Name
     }).ToList() ?? new List <ReleaseDate>();
     Summary = model.Summary;
     GameUrl = model.Url;
 }