public ActionResult DeleteConfirmed(int id)
        {
            NightLife nightLife = db.NightLives.Find(id);

            db.NightLives.Remove(nightLife);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #2
0
        public void TestNightLifeHourspanToBig()
        {
            NightLife nightlife            = new NightLife(100);
            DateTime  reservationDateStart = new DateTime(2020, 01, 23, 22, 00, 00);
            DateTime  reservationDateEnd   = new DateTime(2020, 01, 24, 11, 00, 00);
            int       firstHourPrice       = 10;
            Action    act = () => nightlife.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldThrow <ArgumentException>().Message.ShouldBe("Tijdsduur kan maximum 11 uur zijn.");
        }
Пример #3
0
        public void TestNightLifeStartDateToBig()
        {
            NightLife nightlife            = new NightLife(100);
            DateTime  reservationDateStart = new DateTime(2020, 01, 23, 2, 00, 00);
            DateTime  reservationDateEnd   = new DateTime(2020, 01, 23, 9, 00, 00);
            int       firstHourPrice       = 10;
            Action    act = () => nightlife.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldThrow <ArgumentException>().Message.ShouldBe("Startreservatie moet tussen 20 uur en 0 uur zitten.");
        }
Пример #4
0
        public void TestNightLifeStartDateInRange()
        {
            NightLife nightlife            = new NightLife(100);
            DateTime  reservationDateStart = new DateTime(2020, 01, 23, 21, 00, 00);
            DateTime  reservationDateEnd   = new DateTime(2020, 01, 24, 6, 00, 00);
            int       firstHourPrice       = 10;
            Action    act = () => nightlife.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            act.ShouldNotThrow();
        }
 public ActionResult Edit([Bind(Include = "Id,No,Name")] NightLife nightLife)
 {
     if (ModelState.IsValid)
     {
         db.Entry(nightLife).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(nightLife));
 }
        public ActionResult Create([Bind(Include = "Id,No,Name")] NightLife nightLife)
        {
            if (ModelState.IsValid)
            {
                db.NightLives.Add(nightLife);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(nightLife));
        }
Пример #7
0
        public void TestNightLifeReturnsCorrectHours()
        {
            NightLife   nightlife            = new NightLife(100);
            DateTime    reservationDateStart = new DateTime(2020, 01, 23, 21, 00, 00);
            DateTime    reservationDateEnd   = new DateTime(2020, 01, 24, 6, 00, 00);
            int         firstHourPrice       = 10;
            List <Hour> hours = nightlife.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            hours[0].Period.ShouldBe(7);
            hours[0].UnitPrice.ShouldBe(100);
            hours[1].Period.ShouldBe(2);
            hours[1].UnitPrice.ShouldBe(15);
        }
Пример #8
0
        public void TestWellnessGetHoursInvalidValuePrice()
        {
            //Arrange = initialisatie obejcten/methodes
            NightLife nightlife            = new NightLife(null);
            DateTime  reservationDateStart = new DateTime(2020, 01, 23, 21, 00, 00);
            DateTime  reservationDateEnd   = new DateTime(2020, 01, 24, 4, 00, 00);
            int       firstHourPrice       = 10;
            //Act roept test methode op met ingestelde parameters
            Action act = () => nightlife.GetHours(reservationDateStart, reservationDateEnd, firstHourPrice);

            //Assert verifieert of juist
            act.ShouldThrow <InvalidOperationException>().Message.ShouldBe("Arrangement niet beschikbaar");
        }
        // GET: NightLives/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            NightLife nightLife = db.NightLives.Find(id);

            if (nightLife == null)
            {
                return(HttpNotFound());
            }
            return(View(nightLife));
        }
Пример #10
0
        private static List <Limousine> ReadLimousines(List <string[]> file)
        {
            List <Limousine> limos = new List <Limousine>();

            foreach (string[] line in file.Skip(1))
            {
                string             name           = line[0]; //try catch ??
                int                firstHourPrice = int.Parse(line[1]);
                NightLife          nightLife      = new NightLife(parseToNullableInt(line[2]));
                Wedding            wedding        = new Wedding(parseToNullableInt(line[3]));
                Wellness           wellness       = new Wellness(parseToNullableInt(line[4]));
                List <Arrangement> arrangements   = new List <Arrangement>()
                {
                    nightLife, wedding, wellness
                };
                Limousine limo = new Limousine(name, firstHourPrice, arrangements);
                limos.Add(limo);
                Console.WriteLine($"added limo: {limo.Name}");
            }
            return(limos);
        }