public void CreateVideogame(VideoGameEntity videoGame)
 {
     if (videoGame.Company != null)
     {
         _dbContext.Entry(videoGame.Company).State = EntityState.Unchanged;
     }
     _dbContext.Videogames.Add(videoGame);
 }
        public bool DeleteVideogame(int videogameId)
        {
            var videogameToDelete = new VideoGameEntity()
            {
                Id = videogameId
            };

            _dbContext.Entry(videogameToDelete).State = EntityState.Deleted;
            return(true);
        }
Esempio n. 3
0
        public bool UpdateVideogame(VideoGameEntity videoGame)
        {
            var videogameToUpdate = GetVideogame(videoGame.Id);

            videogameToUpdate.Name        = videoGame.Name ?? videogameToUpdate.Name;
            videogameToUpdate.Price       = videoGame.Price ?? videogameToUpdate.Price;
            videogameToUpdate.ReleaseDate = videoGame.ReleaseDate ?? videogameToUpdate.ReleaseDate;
            videogameToUpdate.Genre       = videoGame.Genre ?? videogameToUpdate.Genre;
            videogameToUpdate.ESRB        = videoGame.ESRB ?? videogameToUpdate.ESRB;
            return(true);
        }
        public async Task <bool> UpdateVideogameAsync(VideoGameEntity videoGame)
        {
            var videogameToUpdate = await _dbContext.Videogames.FirstOrDefaultAsync(v => v.Id == videoGame.Id);

            videogameToUpdate.Name        = videoGame.Name ?? videogameToUpdate.Name;
            videogameToUpdate.Price       = videoGame.Price ?? videogameToUpdate.Price;
            videogameToUpdate.ReleaseDate = videoGame.ReleaseDate ?? videogameToUpdate.ReleaseDate;
            videogameToUpdate.Genre       = videoGame.Genre ?? videogameToUpdate.Genre;
            videogameToUpdate.ESRB        = videoGame.ESRB ?? videogameToUpdate.ESRB;
            return(true);
        }
Esempio n. 5
0
        public VideoGameEntity CreateVideogame(VideoGameEntity videoGame)
        {
            int newId;
            var lastVideogame = videogames.OrderByDescending(v => v.Id).FirstOrDefault();

            if (lastVideogame == null)
            {
                newId = 1;
            }
            else
            {
                newId = lastVideogame.Id + 1;
            }
            videoGame.Id = newId;
            videogames.Add(videoGame);
            return(videoGame);
        }
Esempio n. 6
0
 public void TestCleanup()
 {
     videoGameEntity = null;
 }
Esempio n. 7
0
 public void TestInitialize()
 {
     videoGameEntity = A.Fake <VideoGameEntity>();
 }