public List <FavouriteSuperHero> GetUserFavouriteHeroList(string userId)
 {
     using (SuperHeroDBEntities db = new SuperHeroDBEntities())
     {
         var user = AspNetUsersDb.GetUserIncludeFavouriteHeroesByIdAndDb(userId, db);
         return(user.FavouriteSuperHero.ToList());
     }
 }
 public FavouriteSuperHero GetUserFavouriteHeroById(int apiId, string userId)
 {
     using (SuperHeroDBEntities db = new SuperHeroDBEntities())
     {
         var user = AspNetUsersDb.GetUserIncludeFavouriteHeroesByIdAndDb(userId, db);
         return(user.FavouriteSuperHero.Where(h => h.ApiId == apiId).FirstOrDefault());
     }
 }
        public void SaveHeroToDb(FavouriteSuperHero newFavouriteHero, string userId)
        {
            using (SuperHeroDBEntities db = new SuperHeroDBEntities())
            {
                var user = AspNetUsersDb.GetUserIncludeFavouriteHeroesByIdAndDb(userId, db);

                using (DbContextTransaction tran = db.Database.BeginTransaction())
                {
                    newFavouriteHero.AspNetUsers.Add(user);
                    db.FavouriteSuperHero.Add(newFavouriteHero);
                    db.SaveChanges();
                    tran.Commit();
                }
            }
        }