/// <summary> /// Deletes a video game by the games id /// </summary> /// <param name="id">The video game's id</param> /// <param name="context">The database context</param> /// <returns></returns> public static async Task DeleteById(int id, GameContext context) { VideoGame g = new VideoGame() { Id = id }; context.Entry(g).State = EntityState.Deleted; await context.SaveChangesAsync(); }
public static async Task DeleteById(int id, GameContext context) { // Create video game object, with the id of the game we want to remove from the database VideoGame g = new VideoGame() { Id = id }; context.Entry(g).State = EntityState.Deleted; await context.SaveChangesAsync(); }
public static async Task DeleteById(int id, GameContext context) { //Create video game object, with the id of the game we want to remove from the database VideoGame g = new VideoGame() { Id = id }; context.Entry(g).State = EntityState.Deleted; //This tells the Entity Framework that we have the video game object, but we are removing it from the database await context.SaveChangesAsync(); }
public static async Task DeleteById(int id, GameContext context) { // create video game with the id we want to remove VideoGame g = new VideoGame() { Id = id }; // tell context we want to remove this game from the database, then save context.Entry(g).State = EntityState.Deleted; await context.SaveChangesAsync(); }