public ActionResult CreateRestaurant(Resto restaurant) { if (ModelState.IsValid) { using (IDal dal = new Dal()) { if (!dal.RestaurantExiste(restaurant.Nom)) { dal.CreerRestaurant(restaurant.Nom, restaurant.Telephone); return RedirectToAction("Index"); } else { //ViewBag.MessageErreur = "Ce restaurant existe deja !"; ModelState.AddModelError("Nom", "Un restaurant existe deja avec ce nom la !"); return View(); } } } else { ViewBag.MessageErreur = "Valeurs incorrects !"; return View(); } }
public ActionResult ModifierRestaurant(Resto resto) { if (!ModelState.IsValid) { return View(resto); } using (IDal dal = new Dal()) { dal.ModifierRestaurant(resto.Id, resto.Nom, resto.Telephone); return RedirectToAction("Index"); } }