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()); } }
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()); } }
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()); } }
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()); } }
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()); } }
public IEnumerable <Game> getAll() // returns all games on the database. { using (var context = new gameApiContext()) { return(context.Games.ToList()); } }
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()); } }
[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) } }
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()); } }
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()); } }
[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) } }
[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()); } }
[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()); } }