Beispiel #1
0
        public bool CreateGamer(GamerCreate model)
        {
            var entity =
                new Gamer()
            {
                PlayerId     = _gamerId,
                GamerTag     = model.GamerTag,
                FirstName    = model.FirstName,
                LastName     = model.LastName,
                EmailAddress = model.EmailAddress,
                Location     = model.Location,
                Bio          = model.Bio
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Gamers.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Create(GamerCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateGamerService();

            if (service.CreateGamer(model))
            {
                TempData["SaveResult"] = "Your gamer profile was created.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Gamer could not be created.");

            return(View(model));
        }