public ActionResult Edit([Bind(Include = "ID,Name,Type,Price")] BeastVM beast) { if (ModelState.IsValid) { _beastrepo.UpdateBeast(beast); _beastrepo.Complete(); return(RedirectToAction("Index")); } ViewBag.Type = new SelectList(_beastrepo.ContextDB().Type, "Type1", "Type1", beast.Type); return(View(beast)); }
public ActionResult AddCheckedAnimal() { BeastVM beastie = null; var temp = _boekingRepository.TempBooking; var id = int.Parse(Request.Form.Get("BeastID")); var beastieList = _boekingRepository.AnimalsBooked().ToList(); foreach (var item in beastieList) { if (id == item.ID) { beastie = item; } } if (beastie == null) { beastie = new BeastVM(_beastrepo.Get(id)); } if (beastieList.Contains(beastie)) { beastieList.Remove(beastie); temp.Beast = beastieList; _boekingRepository.TempBooking = temp; if (!_boekingRepository.PolarLionExists()) { _beastrepo.ExcludeFarm = false; } if (!_boekingRepository.FarmExists()) { _beastrepo.ExcludePolarLion = false; } InfoBar(); return(RedirectToAction("Step1")); } if (beastie.Name == "Leeuw" || beastie.Name == "Ijsbeer") { _beastrepo.ExcludeFarm = true; } if (beastie.Type == "Boerderij") { _beastrepo.ExcludePolarLion = true; } beastieList.Add(beastie); temp.Beast = beastieList; _boekingRepository.TempBooking = temp; InfoBar(); return(RedirectToAction("Step1")); }
// GET: Beast/Details/5 public ActionResult Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var beast = new BeastVM(_beastrepo.Get(id)); if (beast == null) { return(HttpNotFound()); } return(View(beast)); }
// GET: Beast/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var beast = new BeastVM(_beastrepo.Get(id)); if (beast == null) { return(HttpNotFound()); } ViewBag.Type = new SelectList(_beastrepo.ContextDB().Type, "Type1", "Type1", beast.Type); return(View(beast)); }
public void EditBeast_BeastIsUpdated_Test() { //1. Arrange _beastcontroller = new BeastController(_beastRepository.Object, _accessoryRepository.Object, _boekingsRepository.Object); var Beast = new BeastVM { Name = "Leeuw" }; //2. Act _beastcontroller.Edit(Beast); //3.Assert _beastRepository.Verify(b => b.UpdateBeast(Beast), Times.Once()); }
public void AddCheckAnimalRedirect_Step1_Test() { //1. Arrange _boekingsRepository.SetupGet(b => b.TempBooking).Returns(new BookingVM()); var Controller = new BookingController(_boekingsRepository.Object, _beastRepository.Object, _accessoryRepository.Object, _contactpersonRepository.Object); var Beast = new BeastVM { Name = "Leeuw" }; //2. Act var result = (RedirectToRouteResult)Controller.AddCheckedAnimal(Beast); result.RouteValues["action"].Equals("Step1"); //3. Assert Assert.AreEqual("Step1", result.RouteValues["action"]); }
public ActionResult DeleteConfirmed(int id) { var beast = new BeastVM(_beastrepo.Get(id)); _accRepo.RemoveRange(beast.Accessory); beast.Accessory.Clear(); _accRepo.Complete(); var temp = beast.Booking; foreach (var item in temp) { item.Beast.Remove(beast); } _boekingRepository.RecalculateTotalPrice(temp); _beastrepo.Remove(beast.Beast); _beastrepo.Complete(); return(RedirectToAction("Index")); }
public void CreateBeast_ReturnsBeast_Test() { //1. Arrange _beastcontroller = new BeastController(_beastRepository.Object, _accessoryRepository.Object, _boekingsRepository.Object); _beastcontroller.ModelState.AddModelError("test", "test"); var Beast = new BeastVM { ID = 1, Name = "Leeuw", Type = "Jungle" }; _beastRepository.Setup(b => b.ContextDB()).Returns(new Domain.BeesteOpJeFeestjeEntities()); //2. Act var result = (ViewResult)_beastcontroller.Create(Beast); var SameBeast = (BeastVM)result.ViewData.Model; //3.Assert Assert.AreEqual(Beast.ID, SameBeast.ID); }
public void DeleteConfirmed_RemovesBeast_Test() { //1. Arrange _beastcontroller = new BeastController(_beastRepository.Object, _accessoryRepository.Object, _boekingsRepository.Object); var Beast = new BeastVM { ID = 1, Name = "Leeuw", Type = "Jungle" }; _beastRepository.Setup(b => b.Get(Beast.ID)).Returns(Beast.Beast); _beastRepository.Setup(b => b.ContextDB()).Returns(new BeesteOpJeFeestjeEntities()); //2. Act _beastcontroller.DeleteConfirmed(Beast.ID); //3.Assert _beastRepository.Verify(b => b.Remove(Beast.Beast), Times.Once()); }
public void IndexBeast_ReturnsBeastList_Test() { //1. Arrange _beastcontroller = new BeastController(_beastRepository.Object, _accessoryRepository.Object, _boekingsRepository.Object); var beast = new BeastVM { ID = 1, Name = "Leeuw", Type = "Jungle" }; var List = new List <Beast>(); List.Add(beast.Beast); _beastRepository.Setup(b => b.GetAll()).Returns(List); //2. Act var result = (ViewResult)_beastcontroller.Index(); var SameList = (List <BeastVM>)result.ViewData.Model; //3.Assert Assert.AreEqual(List[0], SameList[0].Beast); }
public void EditBeast_ReturnsInput_Test() { //1. Arrange _beastcontroller = new BeastController(_beastRepository.Object, _accessoryRepository.Object, _boekingsRepository.Object); var Beast = new BeastVM { ID = 1, Name = "Leeuw", Type = "Jungle" }; _beastRepository.Setup(b => b.Get(Beast.ID)).Returns(Beast.Beast); _beastRepository.Setup(b => b.ContextDB()).Returns(new Domain.BeesteOpJeFeestjeEntities()); //2. Act var result = (ViewResult)_beastcontroller.Edit(Beast.ID); var SameBeast = (BeastVM)result.ViewData.Model; //3.Assert Assert.AreEqual(Beast.ID, SameBeast.ID); Assert.AreEqual(Beast.Name, SameBeast.Name); Assert.AreEqual(Beast.Type, SameBeast.Type); }
public void UpdateBeast(BeastVM beast) { Context.Set <Beast>().AddOrUpdate(beast.Beast); }