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; }
public void FillRoom() { room = db.Rooms.Find(this.roomNumber); }
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); }