// GET: Hotelkamers/Create
 public ActionResult Create()
 {
     int[] Groote = new[] { 2, 3, 5 };
     ViewBag.Groote = new SelectList(Groote);
     ViewBag.Type   = new SelectList(Kamer.GetKamers(), "Name", "Description");
     return(View());
 }
        public ActionResult DeleteConfirmed(int id)
        {
            Kamer kamer = db.GetKamerForId(id);

            db.RemoveKamer(kamer);
            return(RedirectToAction("Index"));
        }
Example #3
0
 public void CreateKamer(Kamer kamer)
 {
     using (var context = new MyContext())
     {
         context.Kamers.Add(kamer);
         context.SaveChanges();
     }
 }
Example #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            Kamer kamer = db.Kamers.Find(id);

            db.Kamers.Remove(kamer);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
 public void EditKamer(Kamer kamer)
 {
     using (var context = new MyContext())
     {
         context.Entry(kamer).State = EntityState.Modified;
         context.SaveChanges();
     }
 }
 public void EditKamer(Kamer kamer)
 {
     if (kamer == null)
     {
         throw new ArgumentException();
     }
     _kamerRepo.EditKamer(kamer);
 }
 public void RemoveKamer(Kamer kamer)
 {
     if (kamer == null)
     {
         throw new ArgumentException();
     }
     _kamerRepo.RemoveKamer(kamer);
 }
 public ActionResult Create([Bind(Include = "Id,Beschrijving,Prijs,IsAanbevolen,AantalBedden,Afbeelding")] Kamer kamer)
 {
     if (ModelState.IsValid)
     {
         db.CreateKamer(kamer);
         return(RedirectToAction("Index"));
     }
     return(View(kamer));
 }
Example #9
0
 public void RemoveKamer(Kamer kamer)
 {
     using (var context = new MyContext())
     {
         context.Kamers.Attach(kamer);
         context.Kamers.Remove(kamer);
         context.SaveChanges();
     }
 }
        public void GetKamerForIdReturnsKamer()
        {
            Mock <IKamerRepository> repo = new Mock <IKamerRepository>();

            repo.Setup(k => k.GetKamerForId(It.IsAny <int>())).Returns(_kamers.ElementAt(It.IsAny <int>()));

            Kamer kamer = repo.Object.GetKamerForId(1);

            Assert.IsNotNull(kamer);
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "Kamer_ID,Kamernaam,Afdeling_ID")] Kamer kamer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kamer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kamer));
 }
 public ActionResult Edit(HotelkamerModel hotelkamer)
 {
     if (ModelState.IsValid)
     {
         _hotelkamerRepository.Update(hotelkamer);
         _hotelkamerRepository.Save();
         return(RedirectToAction("Index"));
     }
     ViewBag.Type = new SelectList(Kamer.GetKamers(), "Name", "Description", hotelkamer.Type);
     return(View(hotelkamer));
 }
Example #13
0
        public ActionResult Create([Bind(Include = "Kamer_ID,Kamernaam,Afdeling_ID")] Kamer kamer)
        {
            if (ModelState.IsValid)
            {
                db.Kamers.Add(kamer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kamer));
        }
        public void RemoveKamer()
        {
            Kamer k = _kamers[0];
            Mock <IKamerRepository> repo = new Mock <IKamerRepository>();

            repo.Setup(r => r.CreateKamer(It.IsAny <Kamer>())).Callback((Kamer kamer) => {
                _kamers.Remove(kamer);
            });

            int amount = _kamers.Count;

            repo.Object.CreateKamer(k);
            Assert.AreEqual(_kamers.Count, amount - 1);
        }
Example #15
0
        // GET: Kamer/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Kamer kamer = db.Kamers.Find(id);

            if (kamer == null)
            {
                return(HttpNotFound());
            }
            return(View(kamer));
        }
        // GET: Kamers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Kamer kamer = db.GetKamerForId((int)id);

            if (kamer == null)
            {
                return(HttpNotFound());
            }
            return(View(kamer));
        }
Example #17
0
        public Kamer GetKamerForId(int id)
        {
            Kamer k = null;

            using (var context = new MyContext())
            {
                k = context.Kamers.Find(id);
            }

            if (k == null)
            {
                throw new InvalidOperationException("Kamer with provided id does not exist");
            }
            return(k);
        }
        public ActionResult Bekijk(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Kamer kamer = db.GetKamerForId((int)id);

            kamer.Boekingen = db.GetAllBoekingen().Where(b => b.KamerID.Equals((int)id)).ToList();
            if (kamer == null)
            {
                return(HttpNotFound());
            }
            return(View(kamer));
        }
        // GET: Hotelkamers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HotelkamerModel hotelkamer = _hotelkamerRepository.Get(id.Value);

            if (hotelkamer == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Type   = new SelectList(Kamer.GetKamers(), "Name", "Description", hotelkamer.Type);
            ViewBag.Groote = new SelectList(new int[] { 2, 3, 5 }, hotelkamer.Groote);
            return(View(hotelkamer));
        }
Example #20
0
        // GET: Nacht
        public ActionResult Index()
        {
            List <TamagotchiModel> RoomlessTamagotchis = _tamagotchiRepository.GetAllAlive();

            _hotelkamerRepository.GetAll().Where(t => t.Tamagotchis.Count > 0).ToList().ForEach((h) =>
            {
                foreach (var objTamagotchi in h.Tamagotchis)
                {
                    for (int i = 0; i < RoomlessTamagotchis.Count; i++)
                    {
                        if (RoomlessTamagotchis[i].Id == objTamagotchi.Id)
                        {
                            RoomlessTamagotchis.Remove(RoomlessTamagotchis[i]);
                            i--;
                        }
                    }
                }
            });

            RoomlessTamagotchis.ForEach((t) =>
            {
                t.Verveling  += 20;
                t.Gezondheid -= 20;
                t.Leeftijd   += 1;
                t.Level      += 1;
                _tamagotchiRepository.Update(t);
            });
            _tamagotchiRepository.Save();

            _hotelkamerRepository.GetAll().Where(h => h.Tamagotchis.Count > 0).ToList().ForEach(k =>
            {
                IKamer kamer = Kamer.GetKamer(k.Type);
                kamer.Nacht(k.Tamagotchis.Select(t => new TamagotchiModel()
                {
                    _tamagotchi = t
                }).ToList());
                _hotelkamerRepository.Update(k);
                _hotelkamerRepository.Save();
                k.Tamagotchis.Clear();
                _hotelkamerRepository.Update(k);
                _hotelkamerRepository.Save();
            });

            TempData["NachtComplete"] = "Er is een nieuwe dag aangebroken!";

            return(RedirectToAction("Index", "Home"));
        }
Example #21
0
        public ActionResult Tamagotchis(int id)
        {
            if (TempData["Errorlist"] != null)
            {
                ViewBag.Errorlist = TempData["Errorlist"].ToString();
            }

            BoekingModel    boekingModel = new BoekingModel();
            HotelkamerModel hotelkamer   = _hotelkamerRepository.Get(id);

            hotelkamer.Prijs = Kamer.GetKamer(hotelkamer.Type).Price;

            if (hotelkamer != null)
            {
                boekingModel.Hotelkamer = hotelkamer;
            }

            List <TamagotchiModel> tamagotchis = _tamagotchiRepository.GetAllAlive().Where(t => t.Centjes >= hotelkamer.Prijs).ToList();

            if (tamagotchis.Count > 0)
            {
                _hotelkamerRepository.GetAll().Where(t => t.Tamagotchis.Count > 0).ToList().ForEach((h) =>
                {
                    foreach (var objTamagotchi in h.Tamagotchis)
                    {
                        for (int i = 0; i < tamagotchis.Count; i++)
                        {
                            if (tamagotchis[i].Id == objTamagotchi.Id)
                            {
                                tamagotchis.Remove(tamagotchis[i]);
                                i--;
                            }
                        }
                    }
                });

                boekingModel.AvTamagotchis = tamagotchis;
                return(View(boekingModel));
            }

            return(Index());
        }
Example #22
0
        public void AllValuesMatch()
        {
            DateTime    boekingStart = new DateTime(2000, 10, 9);
            List <Gast> gasten       = new List <Gast> {
                new Gast()
                {
                    Naam = "Pietje"
                }
            };
            int   id    = 10;
            Kamer kamer = new Kamer()
            {
                Id = 1
            };
            int kamerId           = 1;
            int kortinspercentage = 20;

            Boeking boeking = new Boeking()
            {
                BoekingStart       = boekingStart,
                Gasten             = gasten,
                Id                 = id,
                Kamer              = kamer,
                KamerID            = kamerId,
                Kortingspercentage = kortinspercentage
            };
            int aantalMensen = 3;

            BoekingVM boekingVM = new BoekingVM(boeking, aantalMensen);

            Assert.AreEqual(boeking.BoekingStart, boekingStart);
            Assert.AreEqual(boeking.Gasten, gasten);
            Assert.AreEqual(boeking.Id, id);
            Assert.AreEqual(boeking.Kamer, kamer);
            Assert.AreEqual(boeking.KamerID, kamerId);
            Assert.AreEqual(boeking.Kortingspercentage, kortinspercentage);
        }
 public void RemoveKamer(Kamer kamer)
 {
     throw new NotImplementedException();
 }
 public void EditKamer(Kamer kamer)
 {
     throw new NotImplementedException();
 }
 public void CreateKamer(Kamer kamer)
 {
     kamers.Add(kamer);
 }
        public void GetKamerForIdThrowsException()
        {
            Mock <KamerRepository> repo = new Mock <KamerRepository>();

            Kamer kamer = repo.Object.GetKamerForId(0);
        }