public ActionResult Create(Restaurant restaurant) { if (ModelState.IsValid) { _unitOfWork.RestaurantRepository.Insert(restaurant); _unitOfWork.Save(); return RedirectToAction("Index"); } return View(restaurant); }
// // GET: /Restaurant/Create // create new restaurant for specific, currently selected town public ActionResult Create(string townName) { ViewBag.CurrentTown = townName; var town = _unitOfWork.TownRepository.Get(filter: t => t.Name == townName).FirstOrDefault(); Restaurant restaurant = new Restaurant(); restaurant.Town = town; restaurant.TownID = town.TownID; return View(restaurant); }