// had to add using

        /// <summary>
        /// Adds a VideoGame to the data store and sets the ID value
        /// </summary>
        /// <param name="g">The game to add</param>
        /// <param name="context">The database context to use</param>
        /// <returns>VideoGame with ID populated</returns>
        public static async Task <VideoGame> Add(VideoGame g, GameContext context)
        {
            await context.AddAsync(g);

            await context.SaveChangesAsync();

            return(g);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds a video game to the data store. Sets the ID value
        /// </summary>
        /// <param name="game">The game to add</param>
        /// <param name="context">The context used</param>
        public static async Task <VideoGame> AddAsync(VideoGame game, GameContext context)
        {
            // NEEDS THE CONTEXT PASSED IN AS WELL
            // must add await keyword
            await context.AddAsync(game);

            await context.SaveChangesAsync();

            return(game);
        }