Beispiel #1
0
        public bool CreateGecko(GeckoCreate model)
        {
            var geckoEntity =
                new Gecko()
            {
                OwnerID        = _userID,
                GeckoName      = model.GeckoName,
                GeckoSexIsMale = model.GeckoSexIsMale,
                GeckoWeight    = model.GeckoWeight,
                HatchDate      = model.HatchDate
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Geckos.Add(geckoEntity);
                return(ctx.SaveChanges() == 1);
            }
        }
Beispiel #2
0
        public ActionResult Create(GeckoCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var service = CreateGeckoService();

            if (service.CreateGecko(model))
            { //changed from viewbag in an attempt at alert in bs4, with update from 3 not working
                TempData["SaveResult"] = "Gecko information has been entered successfully.";
                return(RedirectToAction("Index"));
            }
            ;

            ModelState.AddModelError("", "Gecko information was not saved.");

            return(View(model));
        }