예제 #1
0
        protected override void Seed(KingdomHeartsApplication.DAL.DB context)
        {
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method
            //  to avoid creating duplicate seed data.

            KingdomHeartsGame Game1 = new KingdomHeartsGame
            {
                Title       = "Kingdom Hearts",
                ReleaseDate = 2002
            };

            KingdomHeartsGame Game2 = new KingdomHeartsGame
            {
                Title       = "Kingdom Hearts: Chain of Memories",
                ReleaseDate = 2004
            };

            KingdomHeartsGame Game3 = new KingdomHeartsGame
            {
                Title       = "Kingdom Hearts 2",
                ReleaseDate = 2005
            };

            context.KingdomHeartsGames.AddOrUpdate(KingdomHeartsGame => KingdomHeartsGame.Title, Game1, Game2, Game3);

            context.KingdomHeartsReviews.AddOrUpdate(KingdomHeartsReview => KingdomHeartsReview.Username,
                                                     new KingdomHeartsReview()
            {
                Username = "******", FavoriteGame = "Kingdom Hearts 358/2 Days", HighestDifficulty = "Critical", Rating = 8
            });
        }
        public ActionResult DeleteConfirmed(string id)
        {
            KingdomHeartsGame kingdomHeartsGame = db.KingdomHeartsGames.Find(id);

            db.KingdomHeartsGames.Remove(kingdomHeartsGame);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Title,Description,PlayableCharacter,ReleaseDate")] KingdomHeartsGame kingdomHeartsGame)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kingdomHeartsGame).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kingdomHeartsGame));
 }
        public ActionResult Create([Bind(Include = "Title,Description,PlayableCharacter,ReleaseDate")] KingdomHeartsGame kingdomHeartsGame)
        {
            if (ModelState.IsValid)
            {
                db.KingdomHeartsGames.Add(kingdomHeartsGame);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kingdomHeartsGame));
        }
        // GET: KingdomHeartsGame/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            KingdomHeartsGame kingdomHeartsGame = db.KingdomHeartsGames.Find(id);

            if (kingdomHeartsGame == null)
            {
                return(HttpNotFound());
            }
            return(View(kingdomHeartsGame));
        }