예제 #1
0
        public async Task <IActionResult> PutPublisherModel(int id, PublisherModel publisherModel)
        {
            if (id != publisherModel.PublisherId)
            {
                return(BadRequest());
            }

            _context.Entry(publisherModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PublisherModelExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
        public bool updateVideoGame(VideoGame videoGame)
        {
            using (var db = new VideoGameContext())
            {
                var videoGameTarget = db.VideoGames.Where(vg => vg.VideoGameId == videoGame.VideoGameId).FirstOrDefault();

                try
                {
                    db.Entry(videoGameTarget).CurrentValues.SetValues(videoGame);
                    db.SaveChanges();
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }