public void Remove() { try { GamesContext context = new GamesContext(); context.Entry(this).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } catch (Exception) { throw; } }
internal static List <Videogames> Getranking() { List <Videogames> games = new List <Videogames>(); GamesContext context = new GamesContext(); try { games = context.Videogames.OrderByDescending(x => x.score).ToList(); } catch (Exception) { throw; } return(games); }
public static List <Videogames> GetGames() { List <Videogames> games = new List <Videogames>(); GamesContext context = new GamesContext(); try { games = context.Videogames.OrderBy(x => x.name).ToList(); } catch (Exception) { throw; } return(games); }
// VER internal static Videogames GetGame(int id) { Videogames game = null; try { GamesContext Context = new GamesContext(); game = Context.Videogames.Where(x => x.id == id).SingleOrDefault(); } catch (Exception) { throw; } return(game); }
//SAVE public void Save() { bool create = this.id == 0; try { GamesContext context = new GamesContext(); if (create) { context.Entry(this).State = System.Data.Entity.EntityState.Added; } else { context.Entry(this).State = System.Data.Entity.EntityState.Modified; } context.SaveChanges(); } catch (Exception) { throw; } }