Beispiel #1
0
        public ActionResult Create(Room room)
        {
            if (ModelState.IsValid)
            {
                db.Rooms.Add(room);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.NumberOfPersons = new SelectList(db.RoomNumberOfPersons, "type", "type", room.NumberOfPersons);
            return View(room);
        }
        /* Between Januari and May the minimum price is active, between June and September there is
         * an increase of 50%, from November untill Januari there is an increase of 30%
         * */
        public static double CalculateTotalPrice(Room roomToGetMinimumPriceFrom, int startDate)
        {
            double minPrice = Convert.ToDouble(roomToGetMinimumPriceFrom.MinimumPrice);
            int dateOfArival = startDate;

            if (dateOfArival >= 1 && dateOfArival <= 4)
            {
                return minPrice;
            }
            else if (dateOfArival >= 5 && dateOfArival <= 9)
            {
                double newPrice = (minPrice * 1.5);
                return newPrice;
            }
            else if (dateOfArival >= 9 && dateOfArival <= 12)
            {
                double newPrice = (minPrice * 1.3);
                return newPrice;
            }

            return -1.0;
        }
Beispiel #3
0
 public void FillRoom()
 {
     room = db.Rooms.Find(this.roomNumber);
 }
Beispiel #4
0
 public ActionResult Edit(Room room)
 {
     if (ModelState.IsValid)
     {
         db.Entry(room).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.NumberOfPersons = new SelectList(db.RoomNumberOfPersons, "type", "type", room.NumberOfPersons);
     return View(room);
 }