public void EditBeestje(BeestjeVM beest) { Beestje beestje = db.Beestjes.First(b => b.Id == beest.Id); beestje.Name = beest.Name; beestje.Type = beest.Type; beestje.Price = beest.Price; beestje.ImagePath = beest.ImagePath; db.Entry(beestje).State = EntityState.Modified; db.SaveChanges(); }
public void AddBeestje(BeestjeVM beest) { Beestje beestje = new Beestje(); beestje.Name = beest.Name; beestje.Price = beest.Price; beestje.ImagePath = beest.ImagePath; beestje.Type = beest.Type; db.Beestjes.Add(beestje); db.SaveChanges(); }
public List <Boeking> GetBoekingenFromBeestje(BeestjeVM beest) { List <Boeking> boekinglist = db.Boekings.Include("Beestjes").ToList(); List <Boeking> beestjesboeking = new List <Boeking>(); foreach (Boeking b in boekinglist) { if (b.Beestjes.Contains(beest.Beest)) { beestjesboeking.Add(b); } } return(beestjesboeking); }
public ActionResult Create([Bind(Include = "Id,Name,Type,Price,imagePath")] BeestjeVM beestje) { if (ModelState.IsValid) { string[] validTypes = new string[] { "Woestijn", "Boerderij", "Sneeuw", "Jungle" }; if (!validTypes.Contains(beestje.Type)) { ViewBag.Error = "Kies uit de types Woestijn, Boerderij, Sneeuw of Jungle."; return(View()); } beestjesRepository.AddBeestje(beestje); return(RedirectToAction("Index", "Beestjes")); } return(View(beestje)); }
// Get an animal and show a page to edit the animal public ActionResult Edit(int?id) { if (id == null) { return(RedirectToAction("Index", "Error")); } Beestje beestje = beestjesRepository.GetBeestjeById(id); if (beestje == null) { return(HttpNotFound()); } BeestjeVM beestjeVM = new BeestjeVM(); beestjeVM.Beest = beestje; return(View(beestjeVM)); }
// Shows the details of an animal public ActionResult Details(int?id) { if (id == null) { return(RedirectToAction("Index", "Error")); } Beestje beestje = beestjesRepository.GetBeestjeById(id); if (beestje == null) { return(HttpNotFound()); } BeestjeVM beestjeVM = new BeestjeVM(); beestjeVM.Beest = beestje; beestjeVM.AccessoiresList = beestjesRepository.GetAccessoiresById(beestjeVM.Id); beestjeVM.AllBoekingen = beestjesRepository.GetBoekingenFromBeestje(beestjeVM); return(View(beestjeVM)); }