Пример #1
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)
            }
        }
Пример #2
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());
     }
 }
Пример #3
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());
     }
 }
Пример #4
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)
            }
        }
Пример #5
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());
     }
 }
Пример #6
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());
     }
 }