public void Remove() { try { VideogameContext context = new VideogameContext(); context.Entry(this).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); } catch (Exception) { throw; } }
public static Videogames Get(int id) { Videogames Videogame = new Videogames(); try { VideogameContext context = new VideogameContext(); Videogame = context.Videogames.Where(x => x.id == id).SingleOrDefault(); } catch (Exception) { throw; } return(Videogame); }
public static List <Videogames> SelectAll() { List <Videogames> Videogame = new List <Videogames>(); try { VideogameContext context = new VideogameContext(); Videogame = context.Videogames.OrderBy(x => x.name).ToList(); } catch (Exception) { throw; } return(Videogame); }
public static List <Videogames> Ranking() { List <Videogames> ranking = new List <Videogames>(); try { VideogameContext context = new VideogameContext(); ranking = context.Videogames.OrderByDescending(x => x.score).ToList(); } catch (Exception) { throw; } return(ranking); }
public void Save() { bool create = this.id == 0; try { VideogameContext context = new VideogameContext(); 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; } }