Esempio n. 1
0
 public ActionResult Edit(int id, FormCollection collection) //The id parameter here refers to the REVIEW ID not the brewery Id
 {
     if (ModelState.IsValid)
     {
         try
         {
             ReviewViewModel review = new ReviewViewModel
             {
                 ReviewID          = id,
                 ReviewDescription = collection["ReviewDescription"],
                 Rating            = (float)Convert.ToDouble(collection["Rating"]),
                 UserID            = Convert.ToInt32(collection["UserID"]),
                 BreweryID         = Convert.ToInt32(collection["BreweryID"])
             };
             UserViewModel user = new UserViewModel
             {
                 Username = "******"
             };
             review.User = user;
             BreweryViewModel brewery = brewLogic.GetBrewery(review.BreweryID);
             review.Brewery = brewery;
             revLogic.PutReview(review);
             return(RedirectToAction("Details", "Brewery", new { id = brewery.BreweryID }));
         }
         catch (Exception)
         {
             return(View("Caught Exception"));
         }
     }
     else
     {
         return(View("Invalid Model State"));
     }
 }