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: Restaurant/Edit/5 public ActionResult Edit(int restID) { PLC.Restaurant rest = new PLC.Restaurant(); try { if (func == null) { func = new PLC.Functionality(); } rest = func.GetRestaurant(restID); } catch (Exception ex) { logger.Error(ex.Message); } return(View(rest)); }
public void TestEdit() { RestaurantController rc = new RestaurantController(); PLC.Functionality func = new PLC.Functionality(); var rest = func.GetRestaurant(1);// grab Carl's Jr. string expected = rest.ToString(); var action = rc.Edit(1) as ViewResult; var r = (PLC.Restaurant)action.Model; string actual = r.ToString(); Assert.AreEqual(expected, actual); }
public void TestDetails() { RestaurantController rc = new RestaurantController(); PLC.Functionality func = new PLC.Functionality(); var rest = func.GetRestaurant(1); int expected = 8; // Carl's Jr. Should have 8 reviews var action = rc.Details(rest) as ViewResult; var model = (List <PLC.Review>)action.Model; int actual = model.Count; Assert.AreEqual(expected, actual); }