public void AddGame(CreateGameModel game)
        {
            var newlyCreatedGame = NewGameConvertedFromCreateGameModelToDbGame(game);

            Games.Add(newlyCreatedGame);
            SaveChanges();
        }
        public Game NewGameConvertedFromCreateGameModelToDbGame(CreateGameModel game)
        {
            var developer = Developers.Single(o => o.Name == game.Developer);
            var publisher = Publishers.Single(o => o.Name == game.Publisher);

            var scoreToAdd = new Rating {
                Score = 0, Votes = 0
            };

            var gameToAdd = new Game {
                Name = game.Name, Genre = game.Genre, Platforms = game.Platforms, ReleasedWhere = game.ReleasedWhere, Theme = game.Theme, Year = game.Year, Developer = developer, DeveloperId = developer.Id, Publisher = publisher, PublisherId = publisher.Id, Score = scoreToAdd
            };

            return(gameToAdd);
        }
        public void EditGame(string id, CreateGameModel gameToEdit)
        {
            var gameAfterEdit = GameByName(id);

            gameAfterEdit.Name          = gameToEdit.Name;
            gameAfterEdit.Platforms     = gameToEdit.Platforms;
            gameAfterEdit.ReleasedWhere = gameToEdit.ReleasedWhere;
            gameAfterEdit.Theme         = gameToEdit.Theme;
            gameAfterEdit.Year          = gameToEdit.Year;
            gameAfterEdit.Genre         = gameToEdit.Genre;
            gameAfterEdit.Developer     = Developers.Single(i => i.Name.Equals(gameToEdit.Developer));
            gameAfterEdit.Publisher     = Publishers.Single(i => i.Name.Equals(gameToEdit.Publisher));
            gameAfterEdit.Score         = Ratings.Single(i => i.Id == (gameAfterEdit.ScoreId));

            Games.Update(gameAfterEdit);
            SaveChanges();
        }