Пример #1
0
 public IEnumerable <Game> getByplatform(string platform) //returns all games on a specific genre
 {
     using (var context = new gameApiContext())
     {
         return(context.Games.Where(Game => Game.GamePlatform == platform).ToList());
     }
 }
Пример #2
0
 public IEnumerable <Game> getByStudio(string studio) //returns all games, filtering by a particular game studio
 {
     using (var context = new gameApiContext())
     {
         return(context.Games.Where(Game => Game.Studio == studio).ToList());
     }
 }
Пример #3
0
 public IEnumerable <Game> getByGenre(string genre) //returns all games on a specific genre
 {
     using (var context = new gameApiContext())
     {
         return(context.Games.Where(Game => Game.Genre == genre).ToList());
     }
 }
Пример #4
0
 public IEnumerable <Studio> getStudioByName(string name) //returns game info by looking for it by his name.
 {
     using (var context = new gameApiContext())
     {
         return(context.Studios.Where(Studio => Studio.StudioName == name).ToList());
     }
 }
Пример #5
0
 public IEnumerable <Game> getByName(string name) //returns game info by looking for it by his name.
 {
     using (var context = new gameApiContext())
     {
         return(context.Games.Where(Game => Game.GameName == name).ToList());
     }
 }
Пример #6
0
        public IEnumerable <Game> getAll() // returns all games on the database.

        {
            using (var context = new gameApiContext())
            {
                return(context.Games.ToList());
            }
        }
Пример #7
0
        public IEnumerable <GameEarning> getvalues() // returns all earnings made on the industrie (the ones on the database. )

        {
            using (var context = new gameApiContext())
            {
                return(context.GameEarnings.ToList());
            }
        }
Пример #8
0
        [HttpPost("newgame")]                                      // lern to test this one propertly

        public IEnumerable <Game> newgame([FromBody] Game auxGame) //receives a a formated json object, then adds it to the database
        {
            using (var context = new gameApiContext())
            {
                context.Add(auxGame);
                context.SaveChanges();
                return(context.Games.Where(Game => Game.GameName == auxGame.GameName).ToList()); //returns the new game in json format (in theory)
            }
        }
Пример #9
0
 public IEnumerable <Game> deletegame(int id)
 {
     using (gameApiContext context = new gameApiContext())
     {
         context.Games.Remove(context.Games.FirstOrDefault(e => e.GameId == id));
         context.SaveChanges();
         return(context.Games.ToList());
     }
 }
Пример #10
0
 public IEnumerable <Studio> deletestudio(string id) //somehow studio id ended up being a string instead of an int, im rolling with it
 {
     using (gameApiContext context = new gameApiContext())
     {
         context.Studios.Remove(context.Studios.FirstOrDefault(e => e.StudioId == id));
         context.SaveChanges();
         return(context.Studios.ToList());
     }
 }
Пример #11
0
        [HttpPost("newstudio")]                                            // lern to test this one propertly

        public IEnumerable <Studio> newstudio([FromBody] Studio auxStudio) //receives a a formated json object, then adds it to the database
        {
            using (var context = new gameApiContext())
            {
                context.Add(auxStudio);
                context.SaveChanges();
                return(context.Studios.Where(Studio => Studio.StudioName == auxStudio.StudioName).ToList()); //returns the studio in json format (in theory)
            }
        }
Пример #12
0
 [HttpPut("updatestudio")]  //requires json formated data and a studio id to update
 public IEnumerable <Studio> updateStudio(string id, [FromBody] Studio auxStudio)
 {
     using (gameApiContext context = new gameApiContext())
     {
         var Studio = context.Studios.FirstOrDefault(e => e.StudioId == id);
         Studio.StudioName = auxStudio.StudioName;
         Studio.StudioId   = auxStudio.StudioId;
         context.SaveChanges();
         return(context.Studios.Where(Studio => Studio.StudioName == auxStudio.StudioName).ToList());
     }
 }
Пример #13
0
 [HttpPut("updategame")]  //requires json formated data and a game id to update
 public IEnumerable <Game> updateGame(int id, [FromBody] Game auxGame)
 {
     using (gameApiContext context = new gameApiContext())
     {
         var game = context.Games.FirstOrDefault(e => e.GameId == id);
         game.GameName     = auxGame.GameName;
         game.GameId       = auxGame.GameId;
         game.Genre        = auxGame.Genre;
         game.GamePlatform = auxGame.GamePlatform;
         game.Studio       = auxGame.Studio;
         context.SaveChanges();
         return(context.Games.Where(Game => Game.GameName == auxGame.GameName).ToList());
     }
 }