Esempio n. 1
0
        public void UpdatePrice(PriceUpdate updateRequest)
        {
            if (updateRequest.Price == CurrentPrice)
            {
                return;
            }

            PriceHistory.Add(updateRequest);

            MonthlyPrices.Add(updateRequest);
            HistoricalPrices.Last().Price = PriceHistory.Where(pu => pu.Date.Year == updateRequest.Date.Year).Average(value => value.Price);
            YearlyPrices.ElementAt(updateRequest.Date.Month - 1).Price = PriceHistory.Where(pu => pu.Date.Year == updateRequest.Date.Year && pu.Date.Month == updateRequest.Date.Month).Average(value => value.Price);

            CurrentPrice = updateRequest.Price;
        }
Esempio n. 2
0
        public GameViewModel(Game game) : this()
        {
            GameID           = game.GameID;
            GameName         = game.GameName;
            URL              = game.URL;
            CoverImageURL    = game.CoverImageURL;
            StoryLine        = game.StoreLine;
            Summary          = game.Summary;
            FirstReleaseDate = game.FirstReleaseDate;
            Published        = game.Published.HasValue ? game.Published.Value : false;

            foreach (var gameGenre in game.GameGenres)
            {
                Genres.Add(
                    new GenreViewModel(gameGenre.Genre)
                    );
            }

            foreach (var gameTheme in game.GameThemes)
            {
                Themes.Add(
                    new ThemeViewModel(gameTheme.Theme)
                    );
            }

            foreach (var gameMode in game.GameModes)
            {
                Modes.Add(
                    new ModeViewModel(gameMode.Mode)
                    );
            }

            foreach (var gamePerspective in game.GamePerspectives)
            {
                Perspectives.Add(
                    new PerspectiveViewModel(gamePerspective.Perspective)
                    );
            }

            foreach (var gameScreenshots in game.GameScreenshots)
            {
                Screenshots.Add(
                    new ScreenshotViewModel(gameScreenshots.Screenshot)
                    );
            }

            foreach (var gamePlatform in game.GamePlatforms)
            {
                Platforms.Add(
                    new PlatformViewModel(
                        gamePlatform.Platform,
                        gamePlatform.ReleaseDate.Value)
                    );

                foreach (var history in gamePlatform.VendorGameHistories)
                {
                    PriceHistory.Add(
                        new PriceHistoryViewModel(history)
                        );
                }
            }


            if (PriceHistory.Count() > 0)
            {
                TodaysPrices  = PriceHistory?.Where(ph => ph.CreatedDate >= DateTime.Today).ToList();
                Cheapest      = TodaysPrices?.GroupBy(ph => ph.Price)?.OrderBy(ph => double.Parse(ph.Key))?.FirstOrDefault()?.Select(ph => ph).ToList();
                CheapestPrice = Cheapest?.FirstOrDefault().Price;
            }

            foreach (var settings in game.GamePlatforms.Select(gp => gp.VendorGameSettings))
            {
                foreach (var setting in settings)
                {
                    Settings.Add(new VendorGameSettingViewModel(setting));
                }
            }
        }
Esempio n. 3
0
 public decimal GetPrice() => PriceHistory
 .Where(p => p.ProductId == Id)
 .OrderByDescending(p => p.DateOfPrice)
 .First().Price;