Beispiel #1
0
 public Genre CreateGenre(Genre genre)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Genres.Add(genre);
         db.SaveChanges();
     }
     return(genre);
 }
Beispiel #2
0
 public Publisher CreatePublisher(Publisher publisher)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Publishers.Add(publisher);
         db.SaveChanges();
     }
     return(publisher);
 }
Beispiel #3
0
 public Game CreateGame(Game game)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Games.Add(game);
         db.SaveChanges();
     }
     return(game);
 }
Beispiel #4
0
 public void UpdateGenre(string name, Genre genre)
 {
     using (GameDBContext db = new GameDBContext())
     {
         var Upgenre = db.Genres.Where(g => g.Name == name).FirstOrDefault();
         Upgenre.Name        = genre.Name;
         Upgenre.Description = genre.Description;
         db.SaveChanges();
     }
 }
Beispiel #5
0
 public void UpdatePublisher(string name, Publisher publisher)
 {
     using (GameDBContext db = new GameDBContext())
     {
         var Uppublisher = db.Publishers.Where(g => g.Name == name).FirstOrDefault();
         Uppublisher.Name    = publisher.Name;
         Uppublisher.License = publisher.License;
         db.SaveChanges();
     }
 }
Beispiel #6
0
 public void DeletePublisher(Publisher publisher)
 {
     using (GameDBContext db = new GameDBContext())
     {
         if (db.Games.Any(g => g.Id == publisher.Id))
         {
             db.Publishers.Remove(publisher);
             db.SaveChanges();
         }
     }
 }
Beispiel #7
0
 public void DeletePublisher(int id)
 {
     using (GameDBContext db = new GameDBContext())
     {
         if (db.Publishers.Any(g => g.Id == id))
         {
             db.Publishers.Remove(db.Publishers.Where(g => g.Id == id).FirstOrDefault());
             db.SaveChanges();
         }
     }
 }
Beispiel #8
0
 public void DeleteGenre(Genre genre)
 {
     using (GameDBContext db = new GameDBContext())
     {
         if (db.Games.Any(g => g.Id == genre.Id))
         {
             db.Genres.Remove(genre);
             db.SaveChanges();
         }
     }
 }
Beispiel #9
0
 public void UpdateGame(string name, Game game)
 {
     using (GameDBContext db = new GameDBContext())
     {
         var Upgame = db.Games.Where(g => g.Name == name).FirstOrDefault();
         Upgame.Name         = game.Name;
         Upgame.YearOfIssue  = game.YearOfIssue;
         Upgame.Genre_Id     = game.Genre_Id;
         Upgame.Publisher_Id = game.Publisher_Id;
         db.SaveChanges();
     }
 }