コード例 #1
0
        public bool BossAdd(BossAdd model)
        {
            var entity = new Boss()
            {
                VideoGameID = model.VideoGameID,
                BossName    = model.BossName,
                BossNotes   = model.BossNotes,
                BossBeaten  = model.BossBeaten
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Bosses.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #2
0
        public ActionResult BossCreate(BossAdd model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var service = CreateBossService();

            if (service.BossAdd(model))
            {
                TempData["SaveResult"] = "Your Boss was created successfully.";
                return(RedirectToAction("Index", "VideoGames"));
            }
            ModelState.AddModelError("", "Boss could not be created.");
            return(View(model));
        }