// // GET: /Restaurant/Create // create new restaurant for specific, currently selected town public ActionResult Create(int id) { RestaurantViewModel restaurantView = new RestaurantViewModel(); restaurantView.TownID = id; return View(restaurantView); }
public ActionResult Create(RestaurantViewModel restaurant) { if (ModelState.IsValid) { if (_restaurantService.Insert(restaurant)) { return RedirectToAction("View", new { id = restaurant.TownID }); } } return View(restaurant); }
public bool Insert(RestaurantViewModel restaurant) { Restaurant domainRestaurant = restaurant.ConvertToDomain(); try { _unitOfWork.RestaurantRepository.Insert(domainRestaurant); _unitOfWork.Save(); } catch { return false; } return true; }
public bool Update(RestaurantViewModel restaurantToUpdate) { Restaurant domainRestaurantToUpdate = restaurantToUpdate.ConvertToDomain(); try { _unitOfWork.RestaurantRepository.Update(domainRestaurantToUpdate); _unitOfWork.Save(); } catch { return false; } return true; }