public ActionResult Edit(PLC.Review rev, Nullable <int> rID) { PLC.Restaurant rest = new PLC.Restaurant(); try { if (func == null) { func = new PLC.Functionality(); } rest = func.GetRestaurant(rev.RestaurantID); if (isValid(rev)) { func.UpdateReview(rev.RestaurantID, rev); return(RedirectToAction("Details", "Restaurant", rest)); } return(RedirectToAction("Details", "Restaurant", rest)); } catch (Exception ex) { logger.Error(ex.Message); return(RedirectToAction("Index", "Restaurant", rest)); } }
public ActionResult Create(PLC.Review review, int restID) { try { if (isValid(review)) { if (func == null) { func = new PLC.Functionality(); } func.AddReview(restID, review); var rest = func.GetRestaurant(restID); return(RedirectToAction("Details", "Restaurant", rest)); } return(RedirectToAction("Index", "Restaurant")); } catch (Exception ex) { logger.Error(ex.Message); return(RedirectToAction("Index", "Restaurant")); } }
// GET: Review/Create public ActionResult Create(int restID) { PLC.Review review = new PLC.Review() { RestaurantID = restID }; return(View(review)); }
// Convert a Restaurant.Review table object to a PLC.Review object public PLC.Review ReviewDataToLibraryReview(Review review) { PLC.Review r = new PLC.Review() { ReviewID = review.ReviewID, Author = review.Author, Rating = review.Rating }; return(r); }
// Convert a PLC.Review object to a Restaurant.Review table object public Review LibraryReviewToDataReview(PLC.Review review) { Review r = new Review() { ReviewID = review.ReviewID, Author = review.Author, Rating = review.Rating }; return(r); }
public bool isValid(PLC.Review rev) { if (rev.Author.Length > 15) // Review author's name should be 15 characters or less { return(false); } else if (rev.Rating <= 0 || rev.Rating > 5) { return(false); } return(true); }
// GET: Review/Delete/5 public ActionResult Delete(PLC.Review rev) { if (func == null) { func = new PLC.Functionality(); } func.DeleteReview(rev.RestaurantID, rev.ReviewID); var rest = func.GetRestaurant(rev.RestaurantID); return(RedirectToAction("Details", "Restaurant", rest)); }
// GET: Review/Edit/5 public ActionResult Edit(PLC.Review review) { return(View(review)); }