public virtual ActionResult Create(LibraryCardViewModel libraryCardViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(libraryCardViewModel);
            }

            var libraryCard = Map<LibraryCardViewModel, LibraryCard>(libraryCardViewModel);
            libraryCardRepository.Add(libraryCard);

            return RedirectToAction("Index");
        }
        public void ShouldPostCreateWhereNotValid()
        {
            var libraryCardViewModel = new LibraryCardViewModel();
            controller.ModelState.AddModelError("key", "model is invalid");

            mocks.ReplayAll();
            var result = (ViewResult)controller.Create(libraryCardViewModel);
            mocks.VerifyAll();

            Assert.Equal(libraryCardViewModel, result.Model);
        }
        public void ShouldPostCreate()
        {
            var libraryCardViewModel = new LibraryCardViewModel();

            Expect.Call(() => libraryCardRepositoryMock.Add(Arg<LibraryCard>.Is.Anything));

            mocks.ReplayAll();
            var result = (RedirectToRouteResult)controller.Create(libraryCardViewModel);
            mocks.VerifyAll();

            Assert.True(result.RouteValues.ContainsValue("Index"));
        }
 public virtual ViewResult Create()
 {
     var libraryCardViewModel = new LibraryCardViewModel();
     return View(libraryCardViewModel);
 }
        public virtual ActionResult Edit(LibraryCardViewModel libraryCardViewModel)
        {
            if (!ModelState.IsValid)
            {
                return View(libraryCardViewModel);
            }

            var libraryCard = libraryCardRepository.Get(libraryCardViewModel.Id);
            if (libraryCard == null)
            {
                return ViewNotFound("No libraryCard with id: " + libraryCardViewModel.Id);
            }

            Map(libraryCardViewModel, libraryCard);

            return RedirectToAction("Index");
        }