public override IEnumerable <Genre> GetAll() { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var allItems = myDb.Genres.ToList(); return(allItems); } }
public bool IsNameExist(Genre item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemByName = myDb.Genres.Where(x => x.GenreName == item.GenreName).FirstOrDefault(); return(itemByName == null?false:true); } }
public override Genre GetById(int id) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemById = myDb.Genres.Find(id); return(itemById); } }
/// <summary> /// check if publisher with specific Id has rows in the game table /// </summary> /// <param name="publisherId"></param> /// <returns></returns> public bool IsPublisherIncluded(int publisherId) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemById = myDb.Games.Where(x => x.PublisherID == publisherId).FirstOrDefault(); return(itemById == null ? false : true); } }
public Publisher GetByPublisherLicense(int licenseNumber) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemByLicense = myDb.Publishers.Where(x => x.LicenseNumber == licenseNumber).FirstOrDefault(); return(itemByLicense); } }
public override int Add(Genre item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { myDb.Genres.Add(item); myDb.SaveChanges(); return(1); } }
public bool IsNameAndYearUnique(Game item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var searchResult = myDb.Games.Where(x => (x.GameName == item.GameName) && (x.YearOfProduction == item.YearOfProduction)).FirstOrDefault(); bool isUnique = searchResult == null ? true : false; return(isUnique); } }
public override bool Delete(Game item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { myDb.Games.Remove(item); myDb.SaveChanges(); return(true); } }
public override bool Update(Genre item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemToUpdateById = myDb.Genres.Find(item.Id); myDb.Entry(itemToUpdateById).CurrentValues.SetValues(item); myDb.SaveChanges(); return(true); } }
public override bool Delete(Genre item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemToUpdateById = myDb.Genres.Find(item.Id); myDb.Genres.Remove(item); myDb.SaveChanges(); return(true); } }
public override bool Delete(Publisher item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemToDelete = myDb.Publishers.Find(item.Id); myDb.Publishers.Remove(itemToDelete); myDb.SaveChanges(); return(true); } }
public IEnumerable <Game> GetGameByPublisherLicense(int licenseNumber) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { // var result = myDb.Games.Join(myDb.Publishers, game => game.PublisherID, publisher => publisher, (game) => new { Name = game.GameName }); var result = myDb.Games.Include(game => game.Publisher).Where(publ => publ.Publisher.LicenseNumber == licenseNumber).ToList(); return(result); } }
public override bool Update(Publisher item) { using (ComputerGamesEntities myDb = new ComputerGamesEntities()) { var itemToUpdateById = myDb.Publishers.Find(item.Id); myDb.Entry(itemToUpdateById).CurrentValues.SetValues(item); // myDb.Entry(itemToUpdateById).State= EntityState.Modified; myDb.SaveChanges(); return(true); } }