コード例 #1
0
 //public ActionResult Create([Bind(Include = "StudentID,Name,Email,Age,Address,City,Zip,State")] Student student)
 public ActionResult AddDog(int profileID, [Bind(Include = "HotDogName,LastTimeAte,LastPlaceAte,Rating")] HotDog dog)
 {
     if (!ModelState.IsValid)
     {
         ViewBag.error = "Please check your form and resubmit";
         return(RedirectToAction("CreateDog", new { id = profileID }));
     }
     try
     {
         profileService.AddDog(new Profile()
         {
             ProfileID = profileID
         }, dog);
         return(RedirectToAction("Details", new { id = profileID }));
     }
     catch (Exception e) {
         ViewBag.error = "Please check your form and resubmit";
         return(RedirectToAction("CreateDog", new { id = profileID }));
     }
 }