コード例 #1
0
 public Genre GetGenre(int id)
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(id != 0 ? db.Genres.Where(game => game.Id == id).FirstOrDefault() : null);
     }
 }
コード例 #2
0
 public List <Game> GetGames(int license = 0)
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(license == 0 ? db.Games.Include("Publisher").Include("Genre").ToList() : db.Games.Include("Publisher").Include("Genre").Where(s => s.Publisher.License == license).ToList());
     }
 }
コード例 #3
0
 public Publisher GetPublisher(int id)
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(id != 0 ? db.Publishers.Where(game => game.Id == id).FirstOrDefault() : null);
     }
 }
コード例 #4
0
 public List <Publisher> GetPublishers()
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(db.Publishers.ToList());
     }
 }
コード例 #5
0
 public Game GetGame(int id)
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(id != 0 ? db.Games.Include("Publisher").Include("Genre").Where(game => game.Id == id).FirstOrDefault() : null);
     }
 }
コード例 #6
0
 public List <Genre> GetGenres()
 {
     using (GameDBContext db = new GameDBContext())
     {
         return(db.Genres.ToList());
     }
 }
コード例 #7
0
 public Publisher CreatePublisher(Publisher publisher)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Publishers.Add(publisher);
         db.SaveChanges();
     }
     return(publisher);
 }
コード例 #8
0
 public Genre CreateGenre(Genre genre)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Genres.Add(genre);
         db.SaveChanges();
     }
     return(genre);
 }
コード例 #9
0
 public Game CreateGame(Game game)
 {
     using (GameDBContext db = new GameDBContext())
     {
         db.Games.Add(game);
         db.SaveChanges();
     }
     return(game);
 }
コード例 #10
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();
     }
 }
コード例 #11
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();
     }
 }
コード例 #12
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();
         }
     }
 }
コード例 #13
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();
         }
     }
 }
コード例 #14
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();
         }
     }
 }
コード例 #15
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();
     }
 }