public ActionResult AddDishFeedback(int id) { string user = User.Identity.GetUserId(); dish d = DataManager.Dish.GetDishById(id); if(d == null || user == d.Id_User) { return RedirectToAction("index", "profile"); } DishReviewViewModel model = new DishReviewViewModel { ID_Dish = d.Id_Dish, DishName = d.Name, Image_Url = d.ImageUrl }; return View(model); }
public ActionResult AddDishFeedback(DishReviewViewModel model) { string user = User.Identity.GetUserId(); dish d = DataManager.Dish.GetDishById(model.ID_Dish); if (d == null || user == d.Id_User) { return RedirectToAction("index", "profile"); } if (!ModelState.IsValid) { return View(model); } DataManager.Dish.AddDishReview(user, model.ID_Dish, model.Mark, model.Review); return RedirectToAction("dishinfo", "profile", new { id = model.ID_Dish }); }
public ActionResult EditDishReview(DishReviewViewModel model) { string user = User.Identity.GetUserId(); dishreview review = DataManager.Dish.GetDishReviewById(model.ID_Review); if (review == null || user != review.Id_Owner) { return RedirectToAction("index", "profile"); } if (!ModelState.IsValid) { return View(model); } DataManager.Dish.EditDishReview(model.ID_Review, model.Mark, model.Review); return RedirectToAction("dishinfo", "profile", new { id = model.ID_Dish }); }
public ActionResult EditDishReview(int id) { string user = User.Identity.GetUserId(); dishreview review = DataManager.Dish.GetDishReviewById(id); if (review == null || user != review.Id_Owner) { return RedirectToAction("index", "profile"); } var dish = DataManager.Dish.GetDishById(review.Id_Dish); DishReviewViewModel model = new DishReviewViewModel { ID_Dish = review.Id_Dish, DishName = dish.Name, Image_Url = dish.ImageUrl, ID_Review = review.Id_Review, Mark = (int)review.Mark, Review = review.Description }; return View(model); }