public ActionResult Delete(int id) { EfFilmRepository repo = new EfFilmRepository(); repo.Delete(repo.SelectById(id)); return(RedirectToAction("List")); }
public void IT_SaveOrder() { //Arrange IOrderService orderService = new OrderService(new EfFilmRepository(), new EFOrderRepository(), new Order()); IFilmRepository filmRepository = new EfFilmRepository(); //act orderService.AddFilmToOrder(1); orderService.SaveOrder("Ben"); long film1StockLevelAfterCallingSaveOrder = filmRepository.SelectById(1).Stock; //Assert Assert.AreEqual(9, film1StockLevelAfterCallingSaveOrder); }
public void IT_DbFilmRepository() { IFilmRepository sut = new EfFilmRepository(); Assert.AreEqual(5, sut.SelectAll().Count(), "assertion 1"); Assert.AreEqual(4, sut.SearchByTitle("the").Count(), "assertion 2"); Film film1 = new Film("Aliens", new DateTime(1984, 1, 20), 5, Genre.Science_Fiction); Film film2 = new Film("The Matrix", new DateTime(1999, 5, 18), 2, Genre.Science_Fiction); //act long id1 = sut.Insert(film1); long id2 = sut.Insert(film2); Assert.AreEqual(film1.Title, sut.SelectById(id1).Title, "assertion 3"); Assert.AreEqual(film2.Title, sut.SelectById(id2).Title, "assertion 4"); film1 = sut.SelectById(id1); film1.Stock = 0; sut.Update(film1); Assert.AreEqual(0, sut.SelectById(id1).Stock, "assertion 5"); sut.Delete(film2); Assert.IsNull(sut.SelectById(id2), "assertion 6"); }
public ActionResult Edit(int id) { EfFilmRepository repo = new EfFilmRepository(); return(View(repo.SelectById(id))); }