Exemplo n.º 1
0
        private async Task <int> AddGame(SteamAppDetails fullApp)
        {
            var releasedDate = fullApp.ReleaseDate.ReleaseDate;

            var fullGameModel = new FullGameAddModel
            {
                Title            = fullApp.Name,
                Type             = fullApp.Type,
                Website          = fullApp.Website,
                Description      = fullApp.Description,
                HeaderImage      = fullApp.HeaderImage,
                Background       = fullApp.Background,
                About            = fullApp.About,
                ShortDescription = fullApp.ShortDescription,
                ReleaseDate      = new ReleaseDateAddModel()
                {
                    ComingSoon   = fullApp.ReleaseDate.ComingSoon,
                    ReleasedDate = String.IsNullOrEmpty(releasedDate) ? "Not confirmed" : releasedDate
                },
                steamApp = new SteamAppAddModel()
                {
                    SteamAppId  = fullApp.SteamAppID,
                    SteamReview = fullApp.Reviews,
                    Valid       = true
                }
            };



            return(await _gameManager.AddFullGameAsync(fullGameModel));
        }
Exemplo n.º 2
0
        public async Task <int> AddFullGameAsync(FullGameAddModel gameAddModel)
        {
            string query = $@"INSERT INTO game (Title, Type, About, Website, Thumbnail, Description,
                   HeaderImage, Background,SteamAppId, ReleaseDateId, ShortDescription) OUTPUT Inserted.GameId 
            VALUES(@Title, @Type,@About, @Website,@Thumbnail, @Description,
                   @HeaderImage, @Background,@SteamAppId, @ReleaseDateId, @ShortDescription)";

            return(await SaveDataAsync(query, gameAddModel));
        }
Exemplo n.º 3
0
        public async Task <int> AddFullGameAsync(FullGameAddModel game)
        {
            var validator = DataValidatorHelper.Validate(game);

            if (validator.IsValid)
            {
                var gameDB = await _gamedbAccess.GetGameByTitleAsync(game.Title);

                if (gameDB == null)
                {
                    Console.WriteLine($"{game.Title} has been added");

                    var releaseDateID = await AddReleaseDate(game.ReleaseDate);

                    var steamAppID = await AddSteamApp(game.steamApp);

                    game.SteamAppId    = steamAppID;
                    game.ReleaseDateId = releaseDateID;

                    return(await _gamedbAccess.AddFullGameAsync(game));
                }

                if (gameDB.ReleaseDateID == null || gameDB.ReleaseDateID == 0)
                {
                    var releaseDateID = await AddReleaseDate(game.ReleaseDate);

                    AddReleaseDateToGameAsync(new ReleaseDateToGameModel
                    {
                        GameId = gameDB.GameID, ReleaseDateId = releaseDateID
                    });
                }
                else
                {
                    // check if release date is correct
                    await ValidateReleaseDate(gameDB.ReleaseDateID, game.ReleaseDate);
                }

                if (gameDB.SteamAppId == null || gameDB.SteamAppId == 0)
                {
                    var steamAppId = await AddSteamApp(game.steamApp);

                    AddSteamAppToGameAsync(new SteamAppToGameModel
                    {
                        GameId = gameDB.GameID, SteamAppId = steamAppId
                    });
                }

                return(gameDB.GameID);
            }

            Console.WriteLine($"Invalid Data from {nameof(FullGameAddModel)}");
            validator.Errors.ForEach(e => Console.WriteLine(e));

            throw new Exception("Some data are invalid");
        }