Пример #1
0
        public virtual ActionResult Edit(RestaurantEditViewModel restaurantEditViewModel)
        {
            var restaurant = _restaurantRepository.GetById(restaurantEditViewModel.Id);
            if (restaurant == null)
            {
                return HttpNotFound();
            }

            if (!ModelState.IsValid)
            {
                restaurantEditViewModel.ReviewsViewModel = Mapper.Map<List<ReviewIndexViewModel>>(restaurant.Reviews);
                return View(restaurantEditViewModel);
            }

            Mapper.Map(restaurantEditViewModel, restaurant);

            _restaurantRepository.Update(restaurant);

            return RedirectToAction(Views.ViewNames.Index);
        }
 public void testInitialize()
 {
     _restaurantCreateViewModel = _fixture.Create<RestaurantEditViewModel>();
     _validator = new RestaurantEditViewModelValidator();
 }