public void UpdatePlaystationGame(int id, PlaystationUpdateModel playstationGameToUpdate)
 {
     using (ApplicationDbContext context = new ApplicationDbContext())
     {
         var entities = context.PlaystationGames.Find(id);
     }
 }
Example #2
0
        public IHttpActionResult Update(int id, [FromBody] PlaystationUpdateModel game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _playstationService = new PlaystationService();

            _playstationService.UpdatePlaystationGame(id, game);

            return(Ok());
        }
        public void UpdatePlaystationGame(int id, PlaystationUpdateModel playstationGameToUpdate)
        {
            using (ApplicationDbContext context = new ApplicationDbContext())
            {
                var playstationGameWeWantToUpdate = context.PlaystationGames.Find(id);
                if (playstationGameToUpdate != null)
                {
                    playstationGameWeWantToUpdate.Title          = playstationGameToUpdate.Title;
                    playstationGameWeWantToUpdate.Genre          = playstationGameToUpdate.Genre;
                    playstationGameWeWantToUpdate.Rating         = playstationGameToUpdate.Rating;
                    playstationGameWeWantToUpdate.MaturityRating = playstationGameToUpdate.MaturityRating;
                    playstationGameWeWantToUpdate.Price          = playstationGameToUpdate.Price;

                    context.SaveChanges();
                }
            }
        }