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()); } }
public IActionResult Save(Puppy newPuppy) { puppyDao.SavePuppy(newPuppy); return(RedirectToAction("Index")); }