public IEnumerable <Games> GetGamesByGenre(int GenresId)
        {
            List <Games> Games;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                Games = db.Games.Where(i => i.GenreId == GenresId).ToList();
            }
            return(Games);
        }
        public Games GetByName(string name)
        {
            Games result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                result = db.Games.Where(i => i.Name == name).FirstOrDefault();
            }
            return(result);
        }
        public IEnumerable <Games> GetAll()
        {
            List <Games> games;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                games = db.Games.ToList();
            }
            return(games);
        }
        public Games GetById(int id)
        {
            Games result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                result = db.Games.Where(i => i.Id == id).FirstOrDefault();
            }
            return(result);
        }
        public IEnumerable <Games> GetGamesByPublisher(int PublishersId)
        {
            List <Games> Games;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                Games = db.Games.Where(i => i.PublicherId == PublishersId).ToList();
            }
            return(Games);
        }
        public Games GetByNameYearPublishing(Games Games)
        {
            Games result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                result = db.Games.Where(i => i.Name == Games.Name).ToList().Where(x => x.YearPublishing == Games.YearPublishing).FirstOrDefault();
            }
            return(result);
        }
Beispiel #7
0
        public Publishers GetByName(string name)
        {
            Publishers publishers;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                publishers = db.Publishers.Where(i => i.Name == name).FirstOrDefault();
            }
            return(publishers);
        }
Beispiel #8
0
        public IEnumerable <Publishers> GetAll()
        {
            List <Publishers> publishers;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                publishers = db.Publishers.ToList();
            }
            return(publishers);
        }
Beispiel #9
0
        public Genres GetByName(string name)
        {
            Genres genres;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                genres = db.Genres.Where(i => i.Name == name).FirstOrDefault();
            }
            return(genres);
        }
        public int Delete(Games model)
        {
            int result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                db.Entry(model).State = System.Data.Entity.EntityState.Deleted;
                result = db.SaveChanges();
            }
            return(result);
        }
        public int Create(Games model)
        {
            Games games;
            int   res;

            using (GameStoriesEntities sqlConnection = new GameStoriesEntities())
            {
                games = sqlConnection.Games.Add(model);
                res   = sqlConnection.SaveChanges();
            }
            return(res == 0 ? 0 : games.Id);
        }
Beispiel #12
0
        public int Create(Publishers model)
        {
            Publishers publishers;
            int        res;

            using (GameStoriesEntities sqlConnection = new GameStoriesEntities())
            {
                publishers = sqlConnection.Publishers.Add(model);
                res        = sqlConnection.SaveChanges();
            }
            return(res == 0 ? 0 : publishers.Id);
        }
        public int Update(Games model)
        {
            int result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                Games games = db.Games.Where(i => i.Id == model.Id).FirstOrDefault();
                if (games == null)
                {
                    return(0);
                }

                games  = model;
                result = db.SaveChanges();
            }
            return(result);
        }
Beispiel #14
0
        public int Update(Publishers model)
        {
            int result;

            using (GameStoriesEntities db = new GameStoriesEntities())
            {
                Publishers publisher = db.Publishers.Where(i => i.Id == model.Id).FirstOrDefault();
                if (publisher == null)
                {
                    return(0);
                }

                publisher = model;
                result    = db.SaveChanges();
            }
            return(result);
        }