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); }
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); }
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); }
public void TestCleanup() { videoGameEntity = null; }
public void TestInitialize() { videoGameEntity = A.Fake <VideoGameEntity>(); }