示例#1
0
        public void UpdateXboxGame(XboxUpdatesModel xboxToUpdate)
        {
            using (var ctx = new ApplicationDbContext())
            {
                XboxGame xboxWeWantToUpdate = ctx.XboxGames.Find(xboxToUpdate.Name);

                if (xboxToUpdate != null)
                {
                    xboxWeWantToUpdate.Name   = xboxToUpdate.Name;
                    xboxWeWantToUpdate.Price  = xboxToUpdate.Price;
                    xboxWeWantToUpdate.Rating = xboxToUpdate.Rating;

                    ctx.SaveChanges();
                }
            }
        }
示例#2
0
        public void CreateXboxGame(XboxCreateModel model)
        {
            var xboxToCreate = new XboxGame()
            {
                Name           = model.Name,
                Price          = model.Price,
                Genre          = model.Genre,
                MaturityRating = model.MaturityRating,
                Rating         = model.Rating,
                DeveloperId    = model.DeveloperId,
                PublisherId    = model.PublisherId
            };

            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                ctx.XboxGames.Add(xboxToCreate);
                ctx.SaveChanges();
            }
        }