Beispiel #1
0
        public ActionResult Save([Bind("Name,Weight,Gender,PaperTrained")] Puppy pup)
        {
            try
            {
#if DEBUG
                _logger.LogInformation("POST: Puppies Save called for {0}", pup.Name); // TODO: Implement full logging solution when building production app
#endif
                if (!ModelState.IsValid)
                {
                    ViewData.Add("NoName", 1);
                    return(View("Index", _puppyDao.GetPuppies()));
                }
                _puppyDao.SavePuppy(pup);
                ViewData.Add("NoName", 0);
                return(View("Index", _puppyDao.GetPuppies()));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "{0} - {1}", "Puppies/Save", ex.Message);
                return(View());
            }
        }
Beispiel #2
0
        public IActionResult Save(Puppy newPuppy)
        {
            puppyDao.SavePuppy(newPuppy);

            return(RedirectToAction("Index"));
        }