Example #1
0
        public async Task <IActionResult> PutLanguage(int id, Language language)
        {
            if (id != language.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutPublisher(int id, Publisher publisher)
        {
            if (id != publisher.ID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutReview(int id, Review review)
        {
            if (id != review.ID || !_context.Games.Any(g => g.ID == review.GameId) ||
                !_context.Users.Any(u => u.ID == review.UserId) ||
                !_context.Languages.Any(l => l.ID == review.LanguageId))
            {
                return(BadRequest());
            }

            review.Game     = null;
            review.User     = null;
            review.Language = null;

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

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

            return(NoContent());
        }
Example #4
0
        public async Task <IActionResult> PutGame(int id, Game game)
        {
            if (id != game.ID || !_context.Publishers.Any(p => p.ID == game.PublisherId) ||
                !_context.Developers.Any(d => d.ID == game.DeveloperId))
            {
                return(BadRequest());
            }

            game.Developer = null;
            game.Publisher = null;

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

            try
            {
                _context.UpdateGameGenres(game);
                _context.UpdateGamePlatforms(game);
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }

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

            return(NoContent());
        }